Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main(void) {
- int operation, n;
- float a, b, res;
- while(1) {
- printf("\n1st value: ");
- scanf("%f",&res);
- n=1;
- while(n) {
- printf("\nOperation: ");
- scanf("%i",&operation);
- if(operation>=2&&operation<=5)
- {
- printf("\nValue: ");
- scanf("%f",&b);
- }
- switch(operation){
- case 1: n=0; break;
- case 2: res=res+b; break;
- case 3: res=res-b; break;
- case 4: res=res*b; break;
- case 5: res=res/b; break;
- case 6: res=res/tan(a); break;
- case 7: res=fabs(res); break;
- case 8: res=pow(res,3); break;
- case 9: return 0;
- default: printf("\nInvalid operation number!"); break;
- }
- if(operation>=2&&operation<=8) printf("\nResult: %.3f\n", res);
- }
- }
- }
Add Comment
Please, Sign In to add comment