Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<stdio.h>
  2. int main(){
  3. int optiune = 0;
  4. int x,y;
  5. float z;
  6. while (optiune!=-1)
  7. {
  8. printf("0. introducere numere\n");
  9. printf("1. suma\n");
  10. printf("2. diferenta\n");
  11. printf("3. produs\n");
  12. printf("4. medie\n");
  13. printf("-1. Renunta\n");
  14. fflush(stdout);
  15. scanf("%d", &optiune);
  16. switch (optiune)
  17. {
  18. case -1: break;
  19. case 0: printf("Dati cele doua numere:");
  20. fflush(stdout);
  21. scanf("%d%d",&x,&y);
  22. break;
  23. case 1: z = x + y; break;
  24. case 2: z = x - y; break;
  25. case 3: z = x * y; break;
  26. case 4: z = (float)(x + y)/2; break;
  27. default: {
  28. printf("\nTry again!!!");
  29. }
  30. }
  31. if(optiune > 0)
  32. printf("Rezultatul este: %g\n",z);
  33. }
  34. printf("S-a tastat -1!!!");
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement