Here is source code of the C program which checks a given integer is positive or negative. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C program to check whether a given integer is positive
* or negative
printf("Enter a number \n");
if (number >= 0)
printf("%d is a positive number \n", number);
printf("%d is a negative number \n", number);
$ cc pgm5.c $ a.out Enter a number -10 -10 is a negative number $ a.out Enter a number 45 45 is a positive number
Sanfoundry Global Education & Learning Series – 1000 C Programs.