Skip to content

C Program to check if number is an odd or an even number

by yashan on August 26th, 2011

Write a program in the C programming language to check if the number is an odd number or an even number. Make this C program by using if-else statement. Below is the solution of this C program -

/* Write a C Program to check if the number is an odd number
or an even number */

#include<stdio.h>
void main()
{
     int n;

     printf("Enter any number \n");
     scanf("%d",&n);

     if(n%2!=0)
     {
         printf(" %d is an odd number",n);
     }
     else
     {
         printf("%d is an even number",n);
     }
     getch();
}

Input – Enter any number – 23
Output – 23 is an odd number

2 Comments
  1. #include is missing!

  2. Hijas permalink

    Thanks

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS