Here is source code of the C program which checks a given integer is odd or even. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C program to check whether a given integer is odd or even
int ival, remainder;
printf("Enter an integer : ");
remainder = ival % 2;
if (remainder == 0)
printf("%d is an even integer\n", ival);
printf("%d is an odd integer\n", ival);
$ cc pgm4.c $ a.out Enter an integer : 100 100 is an even integer $ a.out Enter an integer : 105 105 is an odd integer
Sanfoundry Global Education & Learning Series – 1000 C Programs.