C Program to Check the Number is Positive or Negative
In this program, we are taking the value at runtime by the user to check whether it is negative or positive using if else condition.
Code to Check Number is Positive or Negative
#include<stdio.h>
void main()
{
int num;
printf("Enter Any Number");
scanf("%i", &num);
if(num > 1)
{
printf("The number is positive");
}
else if(num < 0)
{
printf("The number is negative");
}
else
{
printf("Invalid Input!");
}
}
void main()
{
int num;
printf("Enter Any Number");
scanf("%i", &num);
if(num > 1)
{
printf("The number is positive");
}
else if(num < 0)
{
printf("The number is negative");
}
else
{
printf("Invalid Input!");
}
}
Comments
Post a Comment