Check positive or negative number in C by R4R Team

Example-
2 is positive
-3 is negative
Syntax-
if(n>0)
poistive
else
negative


program-

#include< stdio.h>
int main()
{
int n;
printf("Enter any number\n");
scanf("%d",&n);
if(n>0)
{
printf("Number is negative");
}
}


output-

Enter any number
34
Number is positive

Enter any number
-2
Number is negative

-In this program, we take an input of the integer number by using %d
-Then using if(n>0), we check that number is positive or not, if number is positive then this condition become true and if body will execute. otherwise it will execute else body.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!