Ans 5. Write an interactive program to do the following operations by providing the choice using the switch statement: 1 - Add two numbers, 2 - Subtract two numbers, 3 - Multiply two numbers, 4 - Divide two numbers, 5 - Exit 1
#include<stdio.h>
int main()
{
int a, b, res, ch;
printf("\nEnter 2 numbers: ");
scanf("%d%d",&a, &b);
printf("\n1 - Add two numbers");
printf("\n2 - Subtract two numbers");
printf("\n3 - Divide two numbers");
printf("\n4 - Multiply two numbers");
printf("\n5 - Exit");
printf("\nEnter your choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:
res = a+b;
break;
case 2:
res = a-b;
break;
case 3:
res = a/b;
break;
case 4:
res = a*b;
break;
}
printf("Result = %d",res);
return 0;
}