prev


While-Loop

49. Prints numbers from the given range (21.7.2009)

/*
Program# 49
date : 28-12-2008
while loop- Prints numbers between given range
*/

#include <stdio.h>
main(){
int a,b,c=0;
printf("\nEnter two numbers :");
scanf("%d %d",&a,&b);
while(a<=b){
printf("\n%d",a);
a=a+1;
}
}

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

$ gcc p49.c

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

$ ./a.out
Enter two numbers :20 30

20
21
22
23
24
25
26
27
28
29
30
$



next
blog comments powered by Disqus