C Program check number is positive or negative using if else
#includeint main() { double num; // constant number printf("Enter a number: "); // enter user scanf("%lf", &num); // storing constant value if (num <= 0.0) // check number is greater or not { 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 : 32 You entered Positive number
0 comments:
Post a Comment