Sunday, 15 December 2013

C Program to Check if a given Integer is Odd or Even

#include < stdio.h>
 
void main()
{
    int ival, remainder;
 
    printf("Enter an integer : ");
    scanf("%d", &ival);
    remainder = ival % 2;
    if (remainder == 0)
        printf("%d is an even integer\n", ival);
    else
        printf("%d is an odd integer\n", ival);
}

Output

 Enter an integer :  100 
 100  is an even integer
 
   
Enter an integer :  105 
 105  is an odd integer

For More Details Please Visit Ictjobs.info

No comments: