Pages

Sunday, October 9, 2011

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 ********************
ANOTHER RULE:

#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();
}

No comments:

Post a Comment