Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- float d1;
- float d2;
- char operation;
- float result;
- printf("Digit 1: ");
- scanf("%f", &d1);
- printf("Operation: |+|-|*|/|");
- scanf(" %c", &operation);
- printf("Digit 2: ");
- scanf("%f", &d2);
- switch(operation){
- case '+':
- result = d1 + d2;
- break;
- case '-':
- result = d1 - d2;
- break;
- case '*':
- result = d1 * d2;
- break;
- case '/':
- result = d1 / d2;
- break;
- default:
- printf("Error");
- }
- printf("Result: %.2f", result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement