WAP to simulate the use of calculator using switch statement

//WAP to simulate the use of calculator using switch statement//

#include<stdio.h>
#include<conio.h>
void main()
{
 int a, b, c, ch;
 printf("Enter the two numbers\n");
 scanf("%d%d", &a, &b);
 printf("1Addition\n2Subtraction\n3Multiplication\n4Division");
 printf("Enter your choice\n");
 scanf("%d", &ch);
 switch(ch)
 {
  case 1: c=a+b;
  printf("Sum is: %d\n", c);
  break;
  case 2: c=a-b;
  printf("Difference is: %d\n", c);
  break;
  case 3: c=a*b;
  printf("Product is: %d\n", c);
  break;
  case 4: c=a/b;
  printf("Quotient is: %d\n", c);
  break;
  default: printf("Wrong choice entered\n");
  break;
  }
 getch();
}                                         


  • The Input and Output of this program is shown in the pictures below:-                                                                                                                                                                                                                                   INPUT                                                                                                                                                                             

                                                                                                                                                                                                             OUTPUT                                                                                                                                                                    



                                                                                                                                                                                    

Comments