Twist_Nemo

Check a Number is Positive or Negative in c

Mar 16th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3.  
  4.     double num;
  5.   printf("Enter your number: \n");
  6.     scanf("%lf", &num);
  7.    
  8.     if (num <= 0.0) {
  9.       if(num == 0.0) {
  10.         printf("Your number is zero \n");
  11.         }
  12.         else {
  13.           printf("Your number is negative \n");
  14.         }
  15.       }
  16.         else {
  17.           printf("Your number is positive \n");
  18.         }
  19.    
  20. return 0;
  21.  
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment