Friday, 9 May 2014

FINDING EVEN OR ODD NUMBER IN C PROGRAM

FINDING EVEN OR ODD NUMBER IN C PROGRAM

#include<stdio.h>     //header file string.h
#include<conio.h>    //header file conio.h
main()                                    //main function
{                                         //start of the program
int a;                                  //variable declaration
clrscr();
printf("enter the number");
scanf("%d",&a);                 //read number from user
if(a%2==0)                     //if statement works only on condition true
{                                       //if statement block runs
printf("you entered number is even");
}                                       //end of if statement block
else                             //when if condition fails else block runs
{                                            //start of else block
printf("you entered number is odd");
}                                             //end of else block
getch();
}                                              //end of the program

No comments:

Post a Comment