Learn about C Program to Find Positive or Negative in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
C Program to Find Positive or Negative
The below program takes the input number from the number. Then it is checked whether the number is greater than 0 or less than 0. The appropriate result will get displayed.
Source code:
#include<stdio.h>
int main()
{
float number;
printf("Enter a number: ");
scanf("%f",&number);
if(number>0)
{
printf("%.1f is a positive number",number);
}
else if(number<0)
{
printf("%.1f is a negative number",number);
}
else
{
printf("Number is zero");
}
return 0;
}
Output:
Enter a number: 5
5.0 is a positive number
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
C Program to Check Number is Multiple of 7 or not
Swap Two Number using a macro in C