C Program For Menu Driven Application using Switch Case

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

// Menu driven application using switch case
#include<stdio.h>
#include<conio.h>
int main()
{
    int a,b,c,choice;
    printf("\n---------------------Menu------------------\n");
    printf("\n 1.Addition\n2.Subtraction\n 3.Swaping\n");
    printf("\n---------------------------------------------\n");
    printf("\nEnter your choice");
    scanf("%d",&choice);
    switch(choice)
    {
         case 1:
         {
            printf("\nEnter two number");
            scanf("%d%d",&a,&b);
            c=a+b;
            printf("Addition of %d and %d is %d",a,b,c);
            break;
         }
        case 2:
         {
            printf("\nEnter two number");
            scanf("%d%d",&a,&b);
            c=a-b;
            printf("Subtraction of %d and %d is %d",a,b,c);
            break;
         }
        case 3:
         {
            printf("\nEnter two number");
            scanf("%d%d",&a,&b);
            printf("Beore swaping %d %d",a,b);
              a=a+b;
              b=a-b;
              a=a-b;
            printf("After swaping %d %d",a,b); 
         }
         default:printf("Invalid choice pls enter from 1 to 3 only ");

    }



    return 0;
}

 

Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *