Question : Write a C Program to check whether a number is positive or negative.
/*
Write a C Program to check whether a number is positive or negative.
*/
#include <stdio.h>
int main()
{
double num;
printf("Enter a number: ");
scanf("%lf", &num);
if (num <= 0.0)
{
if (num == 0.0)
{
printf("You entered 0.");
}
else
{
printf("You entered a negative number.");
}
}
else
{
printf("You entered a positive number.");
}
return 0;
}
OUTPUT :
Enter a number: 12.3
You entered a positive number.
Thank you very much for reading carefully, if you have any other questions, you can share it with us through comments, if this information was important to you, please let us know through comments.
Please do comment and share.
Thank You.
Please do comment and share.
Thank You.
No comments:
Post a Comment