In this program, we will use the C++ switch case to perform for arithmetic operations such as Addition, Subtraction, Multiplication and Division

C++ program to perform arithmetic operations using switch case

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float num_1,num_2;
int operation;

cout<<"What Arithmetic Operation You want to perform:\n";
cout<<"Press 1 for Addition \n" ;
cout<<"Press 2 for Subtraction\n";
cout<<"Press 3 for Multiplication\n";
cout<<"Press 4 for Division\n";
cin>>operation;

cout<<"Now Enter Two Numbers\n";
cin>>num_1>>num_2;

switch (operation)

    {
    case 1:
    cout<<"The Addition result is: "<<num_1+num_2;
    break;

    case 2:
    cout<<"The Subtraction result is: "<<num_1-num_2;
    break;

    case 3:
    cout<<"The Multiplication result is: "<<num_1*num_2;
    break;

    case 4:
    cout<<"The Division result is: "<<num_1/num_2;
    break;
    }
getch();
}

Output:

What Arithmetic Operation You want to perform:

Press 1 for Addition
Press 2 for Subtraction
Press 3 for Multiplication
Press 4 for Division

4

Now Enter Two Numbers

100
30

The Division result is: 3.33333

Leave a Reply

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