•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Software Developers' Lounge section within the Software Development category of DaniWeb, a massive community of 391,709 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,394 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Software Developers' Lounge advertiser:
Views: 12235 | Replies: 81
![]() |
•
•
Join Date: May 2006
Location: Ontario, Canada
Posts: 18
Reputation:
Rep Power: 3
Solved Threads: 2
*Hopefull this hasn't been done already*
Write a program that when run, will print out the numbers 1 through 10. The program can be in any language, and can be as complicated or simple as you want.
Lets see how creative people are, and get up to 500 unique ways!
I'll start out with something simple:
C++
EDIT: I guess we'll let the post count determine the number of different ways that have been produced.
Write a program that when run, will print out the numbers 1 through 10. The program can be in any language, and can be as complicated or simple as you want.
Lets see how creative people are, and get up to 500 unique ways!
I'll start out with something simple:
C++
#include <iostream>
int main() {
int x = 1, y = 10;
while(y--)
std::cout << x++ << std::endl;
}EDIT: I guess we'll let the post count determine the number of different ways that have been produced.
--Jessehk
C#
using System;
class onetoten
{
public static void Main ()
{
for (int x = 0; x < 11; x++)
{
Console.Write(x);
}
}
} Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
•
•
Join Date: May 2006
Location: Ontario, Canada
Posts: 18
Reputation:
Rep Power: 3
Solved Threads: 2
Scheme
(define range
(lambda (s e)
(cond ((< s e) (cons s
(range (+ s 1) e)))
((= s e) (list s))
(else "Invalid function call"))))
(range 1 10) ;=> (1 2 3 4 5 6 7 8 9 10) --Jessehk
3.) VB Script
MsgBox "1, 2, 3, 4, 5, 6, 7, 8, 9, 10", vbOKOnly, "Count!"
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
•
•
Join Date: May 2006
Location: Ontario, Canada
Posts: 18
Reputation:
Rep Power: 3
Solved Threads: 2
C++
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
int main() {
std::vector<int> numbs(0);
for(int x = 1; x <= 10; x++)
numbs.push_back(x);
std::copy(numbs.begin(), numbs.end(), std::ostream_iterator<int>(std::cout, "\n"));
} --Jessehk
•
•
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation:
Rep Power: 11
Solved Threads: 101
•
•
•
•
Originally Posted by tayspen
C#
using System; class onetoten { public static void Main () { for (int x = 0; x < 11; x++) { Console.Write(x); } } }
Blah... you have to show off the features of object orientation:
using System;
using System.Collections.Generic;
using System.Text;
namespace counting
{
public class Counter
{
private int count = 1;
public int Count
{
get
{
return count;
}
set
{
count = value;
}
}
}
class Program
{
public static void Main()
{
Counter number = new Counter();
do
{
Console.WriteLine(number.Count.ToString());
number.Count++;
} while (number.Count <= 10);
}
}
}Looks like a lot more code... Well, it is, but now I've created a reusable object that does all of the work, and I could change it later on so to have a different starting number, or even determine the number some other way.
Alex Cavnar, aka alc6379
That is indeed a better way you did it though. But alot more code 
Another one; Doesnt really 'count" but it prints .
C#
Yea, it's beginner, yet it gets the job done. Now off to create a complicated one.
Jess, was this thread inspire by the one on PFO
.

Another one; Doesnt really 'count" but it prints .
C#
MessageBox.Show("1, 2, 3, 4, 5, 6, 7, 8, 9, 10");Yea, it's beginner, yet it gets the job done. Now off to create a complicated one.
Jess, was this thread inspire by the one on PFO
. Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
FASM Assembly:
format PE console
entry start
include 'C:\fasmw\include\win32a.inc'
;======================================
section '.data' data readable writeable
;======================================
num_fmt db '%d',10,0
;=======================================
section '.code' code readable executable
;=======================================
start:
mov ebx,10
.again:
lea eax,[ebx-11]
neg eax
ccall [printf],num_fmt,eax
dec ebx
jnz .again
stdcall [ExitProcess],0
;=====================================
section '.import' import data readable
;=====================================
library kernel,'kernel32.dll',\
msvcrt,'msvcrt.dll'
import kernel,\
ExitProcess,'ExitProcess'
import msvcrt,\
printf,'printf' Member of: Beautiful Code Club.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Software Developers' Lounge Marketplace
•
•
•
•
ajax asp blog browsing bt business business software creative design developer development devices erp systems experiment firefox howto illustrator india internet malware mcafee media microsoft mmorpg msdn news office online open-source photoshop print project management publishing rss search security software software selection spyware sql super technology evaluation tips toread vista warez web wiki windows
- Previous Thread: Viewing .cdr extension files
- Next Thread: Debuging



Linear Mode