Find all even numbers in given range with C programming
#include<stdio.h>
void main(){
int a, b;
char c;
printf("Enter a smaller number: ");
fflush(stdin);
scanf("%d", &a);
printf("Enter a bigger number: ");
fflush(stdin);
scanf("%d", &b);
if(a > b){
printf("%d is not smaller than %d\n", a, b);
return;
}
c = 0;
do{
if(0 == b%2){
if(!c){
printf("All even numbers: ");
}
printf("%c%d",c,b);
c = ',';
}
b--;
}while(a <= b);
printf("\n");
if(!c){
printf("No even numbers found\n");
}
}
Download
Comments
Post a Comment