In this program user ask to check whether the number is even, odd, -ve, +ve. For this user need to use control statement like if-else. User put the condition if (a==0) then number is zero. if (a%2==0 && a>0) number is even and positive. if (a%2==0 && a<0) number is even and negative or if (a%2!=0 && a>0) number is odd and positive these are some conditions to verify the number pahse. And display result on the screen.
Problem Statement:
This is C program that asks user to check out the number positive, negative or zero.
- Declaring variables.
- Using control statement.
- Display result on the screen.
Here is C source code for checking number phase. The output of this program shown below.
#include <conio.h>
void main ()
{
int a;
clrscr();
printf ("\nEnter a Number : ");
scanf ("%d",&a);
if (a==0)
printf ("\n\nThe Entered number is 0");
if (a%2==0 && a>0)
printf ("\n\nThe Number is Even and +ve");
if (a%2==0 && a<0)
printf ("\n\nThe Number is Even and -ve");
if (a%2!=0 && a>0)
printf ("\n\nThe Number is Odd and +ve");
if (a%2!=0 && a<0)
printf ("\n\nThe Number is Odd and -ve");
getch();
}
Output :
Enter a Number : 10
The Number is Even and +ve