Write a program in C to check whether a number given by the user is zero, positive, or negative

C Programming Language / Decision Making of C Language

947

Program:

#include <stdio.h>
int main()
{
	int x;
	printf("\n ENTER THE NUMBER:");
	scanf("%d", &x);
	if(x > 0)
		printf("x is positive \n");
	else if(x == 0)
			printf("x is zero \n");
		 else
			printf("x is negative \n");
			
    getch();			
	return 0;
}

Output:

Output 1:

 ENTER THE NUMBER:12
x is positive

Output 2

 ENTER THE NUMBER:0
x is zero

Output 3

 ENTER THE NUMBER:-12
x is negative 

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.