ProAnswers.org

Write a C program to perform Menu Driven Calculator ?

#include

#include 

void main() 

{ 

int a,b,c,ch; 

clrscr(); 

printf(“

1.add
2.subtract
3.multiply
4.division
5.remainder
);

printf(“

enter your choice
”);

scanf(“%d”,&ch); 

switch(ch) 

{ 

case1: 

printf(“

enter values of a and b
”);

scanf(“%d%d”,&a,&b); 

c=a+b; 

printf(“

the answer is %d”,c);

break; 

case2: 

printf(“

enter values of a and b
”);

scanf(“%d%d”,&a,&b); 

c=a-b; 

printf(“

the answer is %d”,c);

break; 

case3: 

printf(“

enter values of a and b
”);

scanf(“%d%d”,&a,&b); 

c=a*b; 

printf(“

the answer is %d”,c);

break; 

case4: 

printf(“

enter values of a and b
”);

scanf(“%d%d”,&a,&b); 

c=a/b; 

printf(“

the answer is %d”,c);

break; 

case5: 

printf(“

enter values of a and b
”);

scanf(“%d%d”,&a,&b); 

c=a%b; 

printf(“

the answer is %d”,c);

break; 

default: 

printf(“

enter the correct choice”);

break; 

} 

getch(); 

} 

Output: 

1.add 

2.subtract 

3.multiply 

4.division 

5.remainder 

enter your choice 

2 

enter the values of a and b 

7 

4 

the answer is 3