![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programming Guru
![]() |
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. |
|
|
|
|
|
#2 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
2.) C
#include <stdio.h>
int main(void)
{
for(int i = 1; i<=10; i++)
{
printf("%d\n", i);
}
}
__________________
"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." - Dwight D. Eisenhower |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Feb 2005
Posts: 74
Rep Power: 4
![]() |
__________________
Lorem ipsum dolor sit amet... |
|
|
|
|
|
#4 |
|
Expert Programmer
|
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() ![]() |
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." |
|
|
|
|
|
#6 |
|
Expert Programmer
|
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. |
|
|
|
|
|
#7 |
|
Programming Guru
![]() |
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 |
|
|
|
|
|
#8 |
|
Hobbyist Programmer
|
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. |
|
|
|
|
|
#9 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 556
Rep Power: 5
![]() |
#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);
}
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
|
|
#10 |
|
Professional Programmer
Join Date: Mar 2005
Location: Student of University of Mumbai, Maharashtra State, India
Posts: 344
Rep Power: 4
![]() |
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|