C Program To Create a Calculator using switch case

in Steem Space15 hours ago

Image cover

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;
}

IPFS Video

Posted with Speem

Sort:  

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:

Image

Curated by @alejos7ven

Speak On Steem GIF.gif

Coin Marketplace

STEEM 0.06
TRX 0.32
JST 0.061
BTC 68411.35
ETH 2121.78
USDT 1.00
SBD 0.50