Number is Positive or Negative or Zero: C Program


C Program to check whether the user entered integer number is positive, negative or zero using else if construct.

Note:
Any number greater than 0 is positive.
Any number less than 0 is negative.

Check Whether Number is Positive or Negative or Zero: C Program



YouTube Link: https://www.youtube.com/watch?v=lxNZZJ7NVlE [Watch the Video In Full Screen.]


Check Whether Number is Positive or Negative or Zero: C Program

  1. #include < stdio.h >  
  2.   
  3. int main()  
  4. {  
  5.     int a;  
  6.   
  7.     printf("Enter an integer number\n");  
  8.     scanf("%d", &a);  
  9.   
  10.     if(a > 0)  
  11.     {  
  12.         printf("%d is positive\n", a);  
  13.     }  
  14.     else if(a < 0)  
  15.     {  
  16.         printf("%d is negative\n", a);  
  17.     }  
  18.     else  
  19.     {  
  20.         printf("%d is zero\n", a);  
  21.     }  
  22.   
  23.     return 0;  
  24. }  

Output 1:
Enter an integer number
15
15 is positive

Output 2:
Enter an integer number
-2
-2 is negative

Output 3:
Enter an integer number
0
0 is zero

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

Leave a Reply

Your email address will not be published. Required fields are marked *