Home
User Guide
DB Recovery
Download
Documents
FAQ
Books
About Me
C Programs
Stats

/* Program# 47
   date : 28-12-2008
   while loop-print odd & even numbers between 1 to 10
*/

#include <stdio.h>
main(){
int n,a;
n=1;
while(n<=10){
a=n%2;
if(!a)
printf("\n Even no:%d",n);
else
printf("\n Odd no:%d",n);
n=n+1;
}
}

output:
To compile the program, run the gcc command,
$ gcc p47.c  
Now the executable file is stored as a.out, to run
the program,

$ ./a.out

 Odd no:1
 Even no:2
 Odd no:3
 Even no:4
 Odd no:5
 Even no:6
 Odd no:7
 Even no:8
 Odd no:9
 Even no:10
$ 






Powered by
Open Source Programmers