// C Program to make a Simple Calculator using
// switch-case statements
#include <stdio.h>
#include <float.h>
int main() {
char op='+';
double a=10.5, b=5.4, res;
// Read the operator
// printf("Enter an operator (+, -, *, /): ");
// scanf("%c", &op);
// // Read the two numbers
// printf("Enter two operands: ");
// scanf("%lf %lf", &a, &b);
// Define all four operations in the corresponding
// switch-case
switch (op) {
case '+':
res = a + b;
break;
case '-':
res = a - b;
break;
case '*':
res = a * b;
break;
case '/':
res = a / b;
break;
default:
printf("Error! Incorrect Operator Value\n"); res = -DBL_MAX;
}
if(res!=-DBL_MAX)
return 0;
}
Ly8gQyBQcm9ncmFtIHRvIG1ha2UgYSBTaW1wbGUgQ2FsY3VsYXRvciB1c2luZyAKLy8gc3dpdGNoLWNhc2Ugc3RhdGVtZW50cwojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPGZsb2F0Lmg+CgppbnQgbWFpbigpIHsKICAgIGNoYXIgb3A9JysnOwogICAgZG91YmxlIGE9MTAuNSwgYj01LjQsIHJlczsKCiAgICAvLyBSZWFkIHRoZSBvcGVyYXRvcgogICAgLy8gcHJpbnRmKCJFbnRlciBhbiBvcGVyYXRvciAoKywgLSwgKiwgLyk6ICIpOwogICAgLy8gc2NhbmYoIiVjIiwgJm9wKTsKCiAgICAvLyAvLyBSZWFkIHRoZSB0d28gbnVtYmVycwogICAgLy8gcHJpbnRmKCJFbnRlciB0d28gb3BlcmFuZHM6ICIpOwogICAgLy8gc2NhbmYoIiVsZiAlbGYiLCAmYSwgJmIpOwogICAgCiAgICAvLyBEZWZpbmUgYWxsIGZvdXIgb3BlcmF0aW9ucyBpbiB0aGUgY29ycmVzcG9uZGluZwogICAgLy8gc3dpdGNoLWNhc2UKICAgIHN3aXRjaCAob3ApIHsKICAgIGNhc2UgJysnOgogICAgICAgIHJlcyA9IGEgKyBiOwogICAgICAgIGJyZWFrOwogICAgY2FzZSAnLSc6CiAgICAgICAgcmVzID0gYSAtIGI7CiAgICAgICAgYnJlYWs7CiAgICBj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