Users Online
· Guests Online: 35
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
01 C Program to Check if a given Integer is Odd or Even
This C Program checks if a given integer is odd or even. Here if a given number is divisible by 2 with the remainder 0 then the number is even number. If the number is not divisible by 2 then that number will be odd number.
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
*/
#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);
}
$ 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
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
*/
#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);
}
$ 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
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.