by Dinesh Thakur Category: C Programming (Pratical)

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.

  1. Declaring variables.
  2. Using control statement.
  3. 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
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content