C program source code for a Menu driven Calculator.
/*Menu Driven Calculator*/
/*mechatrofice*/
#include <stdio.h>
#include <conio.h>
void main()
{
int s;
float a,b,add,sub,mul,div;
clrscr();
printf("Enter a=");
scanf("%f",&a);
printf("Enter b=");
scanf("%f",&b);
add=a+b;
sub=a-b;
mul=a*b;
div=a/b;
printf("Enter the choice\n");
printf("For\nAddition Enter 1\n");
printf("Subtraction Enter 2\n");
printf("Multiplication Enter 3\n");
printf("Division Enter 4\n");
scanf("%d",&s);
switch(s) {
case 1:printf("a+b=%f",add);
break;
case 2:printf("a-b=%f",sub);
break;
case 3:printf("a*b=%f",mul);
break;
case 4:printf("a/b=%f",div);
break;
default:printf("Invalid choice ");
}
getch();
}
|
---|
Output