;

C Program to Check Whether the Input Integer Number is Positive or Negative


Tutorialsrack 03/11/2019 C

In this C program, we will learn how to write a program to check whether the input integer number is positive or negative. In this program, we are displaying the message using printf function and read the input taken from the user using scanf function.

Here is the code of the program to check whether the input integer number is positive or negative.

Code - C Program to Check Whether the Input Integer Number is Positive or Negative
/* Description: C program to check whether the input
 * integer number is positive or negative. 
 */
#include <stdio.h>
 
void main()
{
    int num;
 
    printf("Enter a number: \n");
    scanf("%d", &num);
    if (num > 0){
        printf("%d is a positive number \n", num);
		}
    else if (num < 0){
	
        printf("%d is a negative number \n", num);}
    else{
        printf("0 is neither positive nor negative");
		}
}
Output

Enter a number:
5
5 is a positive number

--------------------------------
Process exited after 3.742 seconds with return value 24
Press any key to continue . . .


Related Posts



Comments

Recent Posts
Tags