Advertisement
hamaXD

lab5_4 งานท้ายบทข้อ1

Oct 27th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int abc(int x);
  4. int main()
  5. {
  6.     int x;
  7.     printf("f(x) = x2 + 2x + 3 if x < 0 \nf(x) = 0           if x = 0\nf(x) = x - 2       if x > 0");
  8.     printf("\nEnter number :");
  9.     scanf("%d",&x);
  10.     abc(x);
  11.     return 0;
  12. }
  13. int abc(int x)
  14. {
  15.     int y;
  16.     if(x<0){
  17.         printf("f(x) = x2 + 2x + 3\nf(%d) = %d",x,(x*x)+(x*2)+3);  
  18.     }
  19.     else if(x==0){
  20.         printf("f(x) = 0 \nf(%d) = %d",x,0);
  21.     }
  22.     else{
  23.         printf("f(x) = x - 2 \nf(%d) = %d",x,x-2);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement