pTutorial

New way to learn C programming

C Program to check even or odd

This is a simple c program to check whether an entered number is even or odd using different methods like using modulus operator, conditional operator etc.

Even number: Number is completely divided by 2

C example of check even or odd using modulus operator

#include <stdio.h>
#include <conio.h>
void main()
{
   int n;
 
   printf("Enter an integer\n");
   scanf("%d",&n);
 
   if ( n%2 == 0 )
      printf("Entered number is Even\n");
   else
      printf("Entered number is Odd\n");
 
   getch();

Download C program to check even

Output of program

c program check even or odd

In this example, modulus operator is used to finding the remainder and after that check it's zero if its zero then the number is even otherwise odd.

See Also

Php dollar and double dollar variables   |   Privacypolicy   |   Php strlen function

QUOTES OF THE DAY

Wicked men obey from fear, good men from love

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER