Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.   int main() {
  4.  
  5.     float x;
  6.     float resultado;
  7.  
  8.     scanf("%g", &x);
  9.     if (x < 0) {
  10.     resultado = x + 2;
  11.     }
  12.     else if (x == 0 || x < 2) {
  13.       resultado = (x * x * x) - (5 * x) + 2;
  14.     } else if (x == 2) {
  15.       resultado = (x * x * x) - (5 * x) + 2;
  16.     }
  17.      else if (x > 2) {
  18.       resultado = x + 5;
  19.     }
  20.     printf("%g \n", resultado);
  21.  
  22.   return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement