Solutoion :
#include<stdio.h>
#include<conio.h>
main()
{
int numb;
printf("Please Enter Your Number : ");
scanf("%d",&numb);
if(numb>0)
printf("The
Number Is Positive.");
else
if(numb<0)
printf("\nThe Number Is Negative");
else
printf("\nThe Number Is Zero.");
getch();
}
OR :
#include<stdio.h>
int main()
{
int number;
scanf("%d", &number);
if ( number >0)
printf("postive");
else
{
if (number<0)
printf("negative");
else
printf("zero");
}
}
int main()
{
int number;
scanf("%d", &number);
if ( number >0)
printf("postive");
else
{
if (number<0)
printf("negative");
else
printf("zero");
}
}
Program Analysis :
We use here if and else if decision control statement and made an if else if chain.As we know numbers grater-than zero are positive numbers and less than zero are negative.
Post a Comment