C Program to Implement Calculator
C Program to Implement a Calculator using Switch Case Construct
This Program Performs Addition,Subtraction Division or Multiplication on Given Numbers,A Simple Calculator in C!!
#include<stdio.h>
main()
{
float result,a,b;
char option;
printf("Enter Two Numbers n");
scanf("%ft%f",&a,&b);
printf("Entern+ (Addition)n- (Subtraction)n/ (Division)n* (Multiplication)n");
scanf("%s",&option);
switch(option)
{
case '+':
result=a+b;
break;
case'-' :
result=a-b;
break;
case '/':
result=a/b;
break;
case '*':
result=a*b;
break;
default:printf("Invalid Operator");
}
printf("n%f",result);
}
OUTPUT
Enter Two Numbers
12 14
Enter
+ (Addition)
– (Subtraction)
/ (Division)
* (Multiplication)
+
26.00
Recent Comments