A program that tells number is even or odd.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num;
char ch;
printf("enter any negitive(-) or positive integer(+) : ");
scanf("%c%d",&ch,&num);
if ( num%2 == 0 ) /*for even no reminder should be zero*/
{
if(ch=='+')
{printf("postive Even number\n");}
else
{printf("negitive even number");}
}
else
{
if(ch=='+')
{printf("postive odd number\n");}
else
{printf("negitive odd number");}
}
return 0;
No comments:
Post a Comment