C program to check whether a given number is EVEN or ODD

C program to check whether a given number is EVEN or ODD: Here, we are reading an integer number from the user and checking whether it is EVEN or ODD.

Here I shared the C program for even or odd using an if-else statement.

For example, if the user enters 5 then the output will be:


 Enter a number:5
 5 is an odd number




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


NOTE: You have any problem in the above C program to check whether a given number is EVEN or ODD do not hesitate and write your problem in the comment box. I will support your problem.

No comments:

If you have any doubts, Please let me know

Powered by Blogger.