Write a C program to check whether a given integer number is positive or negative.Read more about C Programming Language . This program is available on GitHub @ https://github.com/snadahalli/cprograms/blob/master/posneg.c
/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
#include <stdio.h>
#include <conio.h>
void main()
{
int number;
clrscr();
printf("Enter a numbern");
scanf ("%d", &number);
if (number > 0)
printf ("%d is a positive numbern", number);
else if (number < 0)
printf ("%d is a negative numbern", number);
else
printf("You entered 0n");
}
Read more Similar C Programs
Searching in C
Number Theory
C Strings
You can easily select the code by double clicking on the code area above.
To get regular updates on new C programs, you can Follow @c_program
You can discuss these programs on our Facebook Page. Start a discussion right now,
our page!
Share this program with your Facebook friends now! by liking it
(you can send this program to your friend using this button)
Like to get updates right inside your feed reader? Grab our feed!
(c) www.c-program-example.com
2 comments on “C program to check whether a given integer number is positive or negative.”
Hey, if I enter 0 as input,
Your code gives the output as Negative integer.
Please implement the if condition as if(number < 0) then print negative. also if 0 is entered it should print Neither +ve nor -ve.
Hello, Thanks for pointing out. I have fixed that.
-Sandeepa