Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- double num1, num2;
- char op;
- while (scanf("%lf %c %lf", &num1, &op, &num2) != EOF){
- /*if (op == '+'){
- printf("%.2lf\n", num1 + num2);
- } else if (op == '-'){
- printf("%.2lf\n", num1 - num2);
- } else {
- fprintf(stderr, "Invalid operation!\n");
- }*/
- switch (op){
- case '+':
- printf("%.2lf\n", num1 + num2);
- break;
- case '-':
- printf("%.2lf\n", num1 - num2);
- break;
- // *-> x , / zeroo
- default:
- fprintf(stderr, "Invalid operation!\n");
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement