WAP in C to Check Whether a Number is Positive or Negative?

#include<stdio.h>
#include<conio.h>
int main()
{
double number;
clrscr();
printf(“Enter a number: “);
scanf(“%lf”, &number);
// true if number is less than 0
if (number < 0.0)
printf(“You entered a negative number.”);
// true if number is greater than 0
else if (number > 0.0)
printf(“You entered a positive number.”);
// if both test expression is evaluated to false
else
printf(“You entered 0.”);
getch();
return(0);
}

Output :-

pos1pos2pos3

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s