Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 13th, 2005, 8:53 PM   #1
Sane
Programming Guru

 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, ON
Posts: 3,485
Rep Power: 10 Sane will become famous soon enoughSane will become famous soon enough
Send a message via MSN to Sane
500 Ways to Program Numbers 1 Through 10!

Let's see if we can do this! Write as many ways (creative or practical) to make a program output numbers 1-10 as you can!

Label what number it is, and the language it's in like I do below.

I'll start us off:

1) Python
import random;x=0
print"["+str(x+1)+",",
for a in range(1,9):
    while x!=a:x=random.randrange(11)
    print str(x+1)+",",;x=x+1
print str(x+1)+"]"


Last edited by Sane; Apr 13th, 2005 at 9:04 PM.
Sane is offline   Reply With Quote
Old Apr 13th, 2005, 9:01 PM   #2
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,475
Rep Power: 8 Mjordan2nd is on a distinguished road
2.) C

 #include <stdio.h>
 
 int main(void)
 {
 	 for(int i = 1; i<=10; i++)
 	 {
 		   printf("%d\n", i);
 	 }
 }
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Apr 13th, 2005, 9:48 PM   #3
dmorales
Programmer
 
Join Date: Feb 2005
Posts: 74
Rep Power: 6 dmorales is on a distinguished road
3) PHP

<? 
for ($i = 1; ; $i++) {
   if ($i > 10) {
       break;
   }
   echo $i;
}


?>
__________________
Lorem ipsum dolor sit amet...
dmorales is offline   Reply With Quote
Old Apr 13th, 2005, 9:49 PM   #4
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 720
Rep Power: 7 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
4) Python
x = 0
while x < 11:
     print x
     x = x +1
simple ehy
thechristelegacy is offline   Reply With Quote
Old Apr 13th, 2005, 9:56 PM   #5
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,484
Rep Power: 10 Infinite Recursion will become famous soon enough
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
5) C++

#include <iostream>
 
 int main(void)
 {
 	 for(int i = 1; i<=10; i++)
 	 {
 		   cout << i << endl; 
 	 }
         
return 0;
 }
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Apr 13th, 2005, 9:57 PM   #6
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 720
Rep Power: 7 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
6) C#
using System;
class count
{
	public static void Main ()
	{
		for (byte x = 0; x < 11; x++)
		{
			Console.Write(x);
		}
	}
}

Last edited by thechristelegacy; Apr 13th, 2005 at 10:01 PM.
thechristelegacy is offline   Reply With Quote
Old Apr 13th, 2005, 9:57 PM   #7
Sane
Programming Guru

 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, ON
Posts: 3,485
Rep Power: 10 Sane will become famous soon enoughSane will become famous soon enough
Send a message via MSN to Sane
7) Python
x=[];b=0
def y(b):
    b=b+1;return b
for a in range(10):b=y(b);x.append(b)
print x
Sane is offline   Reply With Quote
Old Apr 13th, 2005, 10:14 PM   #8
Navid
Hobbyist Programmer
 
Navid's Avatar
 
Join Date: Feb 2005
Location: Canada
Posts: 187
Rep Power: 6 Navid is on a distinguished road
Send a message via MSN to Navid
8) JavaScript

<script language="javascript">

while (i=1, i<2, i=i) {
alert((Math.ceil((Math.random()*10))))
}

</script>

Last edited by navnav; Apr 13th, 2005 at 11:04 PM.
Navid is offline   Reply With Quote
Old Apr 13th, 2005, 10:38 PM   #9
Benoit
The Silent Cryptographer
 
Benoit's Avatar
 
Join Date: Sep 2004
Posts: 736
Rep Power: 6 Benoit is on a distinguished road
#include<stdio.h>
#include<math.h>

main()
{
int i,j;

for(i=0; i<=10; i++)
{
j=i*pow(10,0);
printf("%d\n",j);
}
__________________
Vs lbh nfxrq Oehpr Fpuarvre gb qrpelcg guvf, ur'q pehfu lbhe fxhyy jvgu uvf ynhtu.
Benoit is offline   Reply With Quote
Old Apr 13th, 2005, 11:26 PM   #10
java_roshan
Professional Programmer
 
Join Date: Mar 2005
Location: Student of University of Mumbai, Maharashtra State, India
Posts: 344
Rep Power: 6 java_roshan is on a distinguished road
Well, something to float about in C......

#include<stdio.h>
#include<conio.h>
//Another C code.
void main(){
float i;
clrscr();
for(i=0.5;i<5.5;i+=0.5)
	printf("%.1f\n", (2*i));
getch();
}
__________________
Visit: http://www.somaiya.edu
java_roshan is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:23 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC