C Program To Check Whether The Number Is Positive Or Negative
C Program To Check Whether The Number Is Positive Or Negative
In this example, you will learn to Find Whether The Number Is Positive Or Negative
Example 1 :
number = 10
number is positive
Example 2 :
number = -10
number is negative
Formula To Check Whether The Number Is Positive Or Negative :-
if (num > 0)
print positive
else
print negative
How Program Works ??
- if (num > 0) Condition Check Whether The Number Is Positive Or Negative.
- if num is greater than 0 it return Positive.
- else num is less than 0 it return Negative.
Logic ??
Code For "Check Whether The Number Is Positive Or Negative".
/* Author --> HARSH PATEL */
#include <stdio.h>
void main()
{
int num;
printf("Enter Number : ");
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");
return 0;
}
Output-1
Enter Number : 100
100 is a positive number
Output-2
Enter Number : -100
-100 is a negative number
Output-3
Enter Number : 0
0 is neither positive nor negative
?? Some Image Of Program To Check Whether The Number Is Positive Or Negative
OUTPUT
- Now Program End Without Any Error.
Learn Programming Languages Free In Our Website Coding With Harsh
5000+ Happy Visitor