adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Write a menu based program in C addition, subtraction, multiplication, division using switch case statement.

Write a menu based program in C addition, subtraction, multiplication, division using switch case statement.

 #include<stdio.h>  
 #include<conio.h>  
 #include<stdlib.h>  
   int main()  
   {  
    int a,b,ch,r;  
    clrscr();  
    printf("\tMenu\n");  
    printf("\t1. Addition\n");  
    printf("\t2. Subtraction \n");  
    printf("\t3. Multiplication\n");  
    printf("\t4. Division\n");  
    printf("\t5. Exit\n");  
    printf("\tEnter a choice number:-");  
    scanf("%d",&ch);  
    switch(ch)  
     {  
      case 1:printf("\tEnter two numbers:-");  
         scanf("%d%d",&a,&b);  
         r=a+b;  
         printf("\tSum=%d",r);  
         break;  
      case 2:printf("\tEnter two numbers:-");  
         scanf("%d%d",&a,&b);  
         r=a-b;  
         printf("\tSub=%d",r);  
         break;  
      case 3:printf("\tEnter two numbers:-");  
         scanf("%d%d",&a,&b);  
         r=a*b;  
         printf("\tMul=%d",r);  
         break;  
      case 4:printf("\tEnter two numbers:-");  
         scanf("%d%d",&a,&b);  
         float(r)=a/b;  
         printf("\tDiv=%.1f",r);  
         break;  
      case 5:exit(0);  
         break;  
     default:printf("\tWrong choice");  
     }  
  getch();  
  } 

Output:
   


Post a Comment

0 Comments