golovanovd

prog_lab_2.2

Feb 24th, 2016
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(void) {
  4.     int operation, n;
  5.     float a, b, res;
  6.     while(1) {
  7.        printf("\n1st value: ");
  8.        scanf("%f",&res);
  9.        n=1;
  10.        while(n) {
  11.           printf("\nOperation: ");
  12.           scanf("%i",&operation);
  13.           if(operation>=2&&operation<=5)
  14.           {
  15.              printf("\nValue: ");
  16.              scanf("%f",&b);
  17.           }
  18.           switch(operation){
  19.             case 1: n=0; break;
  20.             case 2: res=res+b; break;
  21.             case 3: res=res-b; break;
  22.             case 4: res=res*b; break;
  23.             case 5: res=res/b; break;
  24.             case 6: res=res/tan(a); break;
  25.             case 7: res=fabs(res); break;
  26.             case 8: res=pow(res,3); break;
  27.             case 9: return 0;
  28.             default: printf("\nInvalid operation number!"); break;
  29.           }
  30.           if(operation>=2&&operation<=8) printf("\nResult: %.3f\n", res);
  31.        }
  32.     }
  33. }
Add Comment
Please, Sign In to add comment