# Write a program that takes a number as input and perform Arithmetic operation like (+,-,/,*) using switch case

## Program that takes a number and perform Arithmetic operation using switch case

### Object: Write a program that takes a number as input and perform Arithmetic operation like (+,-,/,*) using switch case. C++ projects for beginners with source code

### Code:

**#include<iostream>**

**#include<conio.h>**

**using namespace std;**

**void main()**

**{**

**int opt,n1,n2;**

**cout<<“Enter Any Two Numbers\n”;**

**cin>>n1>>n2;**

**cout<<“\nSelect Your Operation\n”;**

**cout<<“\nAddition For Two Numbers Press(1)\n”;**

**cout<<“Subtraction For Two Numbers Press(2)\n”;**

**cout<<“Division For Two Numbers Press(3)\n”;**

**cout<<“Multiplication For Two Numbers Press(4)\n”;**

**cin>>opt;**

**switch (opt)**

**{**

**case 1:**

**cout<<“Addition of Two No. is: “<< n1+n2;**

**break;**

**case 2:**

**cout<<“Subtraction of Two No. is: “<< n1-n2;**

**break;**

**case 3:**

**cout<<“Division of Two No. is: “<< n1/n2;**

**break;**

**case 4:**

**cout<<“Multiplication of Two No. is: “<< n1*n2;**

**break;**

**default:**

**cout<<“Error\nInvalid Operation Select Please Select given Operations.”;**

**break;**

**}**

**getch();**

**}**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include<iostream> #include<conio.h> using namespace std; void main() { int opt,n1,n2; cout<<"Enter Any Two Numbers\n"; cin>>n1>>n2; cout<<"\nSelect Your Operation\n"; cout<<"\nAddition For Two Numbers Press(1)\n"; cout<<"Subtraction For Two Numbers Press(2)\n"; cout<<"Division For Two Numbers Press(3)\n"; cout<<"Multiplication For Two Numbers Press(4)\n"; cin>>opt; switch (opt) { case 1: cout<<"Addition of Two No. is: "<< n1+n2; break; case 2: cout<<"Subtraction of Two No. is: "<< n1-n2; break; case 3: cout<<"Division of Two No. is: "<< n1/n2; break; case 4: cout<<"Multiplication of Two No. is: "<< n1*n2; break; default: cout<<"Error\nInvalid Operation Select Please Select given Operations."; break; } getch(); } |