prev


While-loop

46. Prints numbers from 1 to 10 (21.7.2009)

/*
Program# 46
date : 28-12-2008
while loop-print 1 to 10
*/

#include <stdio.h>
main(){
int n;
n=1;
while(n<=10){
printf("\n %d",n);
n=n+1;
}
}

output:
To compile the program, run the gcc command,

$ gcc p46.c

Now the executable file is stored as a.out, to run
the program,

$ ./a.out

1
2
3
4
5
6
7
8
9
10

$



next
blog comments powered by Disqus