Advertisement
RAJIBRAJU

4.posneg.c

Jul 5th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include<stdio.h>
  2. double negpos(double n)
  3. {
  4.     if(n<0.0)
  5.     {
  6.         return 1;
  7.     }
  8.  
  9.     else if (n>0.0)
  10.     {
  11.         return 2;
  12.  
  13.     }
  14.     else if (n==0.0)
  15.     {
  16.         return 3;
  17.  
  18.     }
  19. }
  20. int main ()
  21. {
  22.     double n,ans;
  23.     scanf("%lf",&n);
  24.     ans=negpos(n);
  25.     if(ans==1)
  26.     {
  27.         printf("negative number");
  28.     }
  29.     else if (ans==2)
  30.     {
  31.         printf("positive number");
  32.         }
  33.         else if (ans==3) {
  34.             printf("zero");
  35.         }
  36.                return 0;
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement