Friday, 13 April 2018

Program to Check Number is Even or Odd

Here we are going to write program to check enter  number is even or odd . We have to know about operator used in C which is most important for applying condition in the program . On the previous blog I told you about operator used in C so please read from there . For writing program to check number is even or odd. As we know that even number are those number which are exactly divisible by 2 and odd number are those which are not divisible by 2. Now we are going to write program.

/*program to check even or odd*/
#include <stdio.h>
void main()
int a;
clrscr ();
printf ("/n Enter a number:");
scanf ("%d", & a);
if ( a%2==0)
printf ("/n a is even number:");
printf ("/n a is odd number :");

From written program you seen that first of all we have to enter a number from the user and then we have used condition for checking. A even number is divisible by 2 then it must gives 0 as remainder then print number is even otherwise it will we odd number. Please comment for any issue in this program for spreading information.


No comments:

Post a Comment

Featured post

Program to find maximum of three number using user define function in C++

A function can be define by the user as per the requirement of the user or programmer . To implement a user define function , a programmer ...