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

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

yashan has written 70 articles

9 thoughts on “C Program to check if number is an odd or an even number

  1. jai patel says:

    This section covers Simple C Programs. Every example program includes the description of the program, C code as well as output of the program. All examples are compiled and tested on a Linux system. The example programs choosen here are Simple & Basic C programs. So, they are suitable for dummies & beginners to C.

Cancel reply

Leave a Reply to ARMAN SINGH

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>