Saturday, January 30, 2010

CHAP 2[C]b Checking for odd or even number

Any integer is input through the keyboard. Write a program to find out whether it is an odd number or even number.

void main()
{
float b;
int a;
printf("\nInput an Integer");
scanf("%d",&a);
b=a%2;
if(b==0)
printf("\nInteger is an even number");
else
printf("\nInteger is an odd number");
}

No comments:

Post a Comment