codescracker


c

C Program to Check Even or Odd



« Previous Program Next Program »


Check Even or Odd in C

To check whether the input number is an even or an odd number in C programming, you have to ask to the user to enter a number now if number is divisible by 2 (it will be even number) and if number is not divisible by 2 (it will be an odd number)

C Programming Code to Check Even or Odd

Following C program ask the user to enter a number, to check and display whether the entered number is odd or even:

/* C Program - Check Even or Odd */
		
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	int num;
	printf("Enter a number :");
	scanf("%d",&num);
	if(num%2==0)
	{
		printf("This is an even number");
	}
	else
	{
		printf("This is an odd number");
	}
	getch();
}

When the above c program is compile and executed, it will produce the following result. Above C Programming Example Output (for even):

c program check even or odd

Above C Programming Example Output (for odd):

c program odd even

Same Program in Other Programming Language

You may also like same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test