Monday, June 18, 2012

To find whether the number entered is even or odd


/* To find whether the number entered is even or odd */

#include<stdio.h>

#include<conio.h>

void main()

{

 int num;

 clrscr();

 printf("Enter any number: ");

 scanf("%d",&num);

 /* Checking for even or odd */

 if(num%2 == 0)

 {

   printf("\n Even Number");

 }

 else

 {

   printf("\n Odd Number");

 }

 getch();

}

 

OUTPUT: 1

Enter any number: 67

 

 Odd Number

 

OUTPUT: 2

Enter any number: 102

 

 Even Number

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.