Advertisement
STANAANDREY

pc5

Oct 5th, 2022
899
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.   while (1) {
  5.    
  6.     puts("1)adunare");
  7.     puts("2)scadere");
  8.     puts("3)inmultire");
  9.     puts("4)impartire");
  10.     puts("5)exit");
  11.     int opt;
  12.     printf("option="); scanf("%d", &opt);
  13.  
  14.     if (opt == 5) {
  15.       break;
  16.     }
  17.  
  18.     float x, y;
  19.     printf("x="); scanf("%f", &x);
  20.     printf("y="); scanf("%f", &y);
  21.  
  22.     float res;
  23.     if (opt == 1) {
  24.       res = x + y;
  25.     } else if (opt == 2) {
  26.       res = x - y;
  27.     } else if (opt == 3) {
  28.       res = x * y;
  29.     } else if (opt == 4) {
  30.       res = x / y;
  31.     }
  32.    
  33.     printf("raspuns=%g\n\n", res);
  34.   }
  35.    
  36.   return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement