Advertisement
Shailrshah

Value of y Based on User-Inputed x

Apr 18th, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.30 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     float x,y;
  5.     printf("Enter the value of x: ");
  6.     scanf("%f",&x);
  7.         if(x>0)
  8.             printf("y = 1");
  9.         if(x <= 0)
  10.         {
  11.             if(x==0)
  12.                 printf("y = 0");
  13.             if(x!=0)
  14.             {
  15.  
  16.                 if (x<0)
  17.                     printf("y = -1");
  18.             }
  19.  
  20.         }  
  21. }
  22. //Output
  23. //Enter the value of x: 0
  24. //y = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement