Your Ad Here

Tuesday, January 22, 2008

Even / Odd Number

/* C Program For Checking whether a number is even or odd */

#include< stdio.h>
#include< conio.h>

void main()
{
int a;
clrscr();
printf("Enter A number : ");
scanf("%d",&a);
if(a%2 != 0)
{
printf("\nThe Number %d Is Odd",a);
}
else if(a%2 == 0)
{
printf("\nThe Number %d Is Even",a);
}
getch();
}
/******************* OUTPUT ********************

Enter A number : 66
The Number 66 Is Even

Enter A number : 37
The Number 37 Is Odd */

15 comments:

Raviraj said...

Great job
its really helps us a lot
thank you very much

cheyenne said...

wow.. thanks to this! =]]

chris said...

what about

if((num & 0x01))
{
cout << "odd";
}
else
{
cout << "even";
}

atul said...

thanks for this program

ahad said...

thanks

Anonymous said...

thankx

Anonymous said...

#include
#include
void main()
{ clrscr() ;
int subject,topic;
printf("enter the number to find odd or even\n");
scanf("%d",&topic);
if (topic%2==0)
{
printf("the number is even%d\n",topic);
}
else
{ printf("the number is odd%d\n",topic);
}





getch();
}




sohail hussain pakistan 2010

Anonymous said...

#include

int main()
{
int a;

printf("Enter Your number that you want to check?");
scanf("%d",&a);
if(a%2==0)
{
printf("The Number Is %d Even\n",a);
}
else
{
printf("The Number %d Is Odd\n",a);
}

}

Anonymous said...

Man I need Explanation
Plzz Help me
whats this %2==0
exactly means
Response somebody plz

Anonymous said...

Man I need Explanation
Plzz Help me
whats this %2==0
exactly means
Response somebody plz

Malavika said...

@Anonymous
it means when u divide any integer with 2, the remainder should be 0 if its an even number...

Anonymous said...

thanks for that! I've been wondering what modulo means...

prabhakar said...

thankss a lot...!

Anonymous said...

These codes not get works on numbers having 12 digit numbers.... Please help..

ani said...

Agorithm please for this program

Your Ad Here