Calculator Program +,-,*,/.
This program help you simple and easy used
addition subtraction multiplication division.
Usage:
step 1: Enter the calculator symbol like +,-,*,/
step 2: Enter the first Number:
step 3: Enter the second Number:
I am using switch operation.
understand this code & run this program.
#include <stdio.h>
int main()
{
float num1, num2, num3;
char op;
printf("Enter the calculator symbol:\n");
scanf("%c", &op);
printf("Enter the First number:");
scanf("%f", &num1);
printf("Enter the Sceond number:");
scanf("%f", &num2);
switch (op)
{
case '-':
num3 = num1 - num2;
printf("%f", num3);
break;
case '+':
num3 = num1 + num2;
printf("%f", num3);
break;
case '*':
num3 = num1 * num2;
printf("%f", num3);
break;
case '/':
num3 = num1 / num2;
printf("%f", num3);
break;
default:
printf("something wrong");
break;
}
return 0;
}
0 Comments