prev | While-Loop 50. Prints odd & even numbers from the given range (21.7.2009) /* Program# 50 date : 28-12-2008 while loop- Prints Odd & Even numbers between given range */ #include <stdio.h> main(){ int a,b,c=0; printf("Enter two numbers :"); scanf("%d %d",&a,&b); while(a<=b){ c=a%2; if(!c) printf("\n Even no:%d",a); else printf("\n odd no:%d",a); a=a+1; } } output: To compile the program, run the gcc command, $ gcc p50.c Now the executable file is stored as a.out, to run the program, $ ./a.out Enter two numbers :50 60 Even no:50 odd no:51 Even no:52 odd no:53 Even no:54 odd no:55 Even no:56 odd no:57 Even no:58 odd no:59 Even no:60 $ |
next |