C Program To Create a Calculator using switch case
Through today's video post, I am sharing a very interesting program with you. With this C program, you can create a calculator and perform four types of tasks: addition, subtraction, multiplication, division. I have created this program very easily and run it and shown it to you and multiplied two numbers. I am giving the C program below, you can copy this program and run this calculator.
#include <stdio.h>
int main() {
char op;
float a, b;
printf("Enter operator (+, -, , /): ");
scanf("%c", &op);
printf("Enter two numbers: ");
scanf("%f %f", &a, &b);
switch(op) {
case '+': printf("%.2f\n", a+b); break;
case '-': printf("%.2f\n", a-b); break;
case '': printf("%.2f\n", a*b); break;
case '/': printf("%.2f\n", a/b); break;
default: printf("Invalid operator\n");
}
return 0;
}
Posted with Speem

Your post have been rewarded by the Speak on Steem curator team!
Now become a plus member delegating at least 500 SP
Ways to support us:
Curated by @alejos7ven