This is a C-Program to print the Positive, Negative of a Odd or Even Number.
#include <stdio.h>
int main()
{
int x;
printf("Enter a Number : ");
scanf("%d",&x);
//To determine positive numbers
if ( x > 0 )
{
if ( x % 2 == 0 )
{
printf("'%d' is a Positive Even Number!\n",x);
}
else
{
printf("'%d' is a Positive Odd Number!\n",x);
}
}
//To determine negative numbers
else if ( x < 0)
{
if ( x % 2 == 0 )
{
printf("'%d' is a Negative Even Number!\n",x);
}
else
{
printf("'%d' is a Negative Odd Number!\n",x);
}
}
else
{
printf("You've Entered 0!\n");
}
return 0;
}
Have a problem.? Then Discuss in Forums here

No comments:
Post a Comment