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

Php5 tostring method   |   Angularjs switch example   |   Php interface

QUOTES OF THE DAY

Knowledge without integrity is dangerous and dreadful.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER