c program to find whether the given number is even or odd..
PROGRAM:
#include <stdio.h>
void main()
{
int num;
printf("Enter a number to find Even or Odd: \n");
scanf("%d",&num); /* taking input from user*/
if (num%2==0) /*checking whether the remainder is zero when divided by 2*/
printf(" The number %d is Even",num);
else
printf(" The number %d is Odd",num);
return(0);
}
void main()
{
int num;
printf("Enter a number to find Even or Odd: \n");
scanf("%d",&num); /* taking input from user*/
if (num%2==0) /*checking whether the remainder is zero when divided by 2*/
printf(" The number %d is Even",num);
else
printf(" The number %d is Odd",num);
return(0);
}
Sample Output: (using GNU GCC Compiler with Code Blocks IDE)
Enter a number to find Even or Odd: 5
The number 5 is Odd
Learn more C programming examples.....
ReplyDeleteLearn C with examples
Basic C programming examples
C pattern programming examples
C Arrays examples
Loops in C examples
if-else in C with examples