## 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();**

**}**

#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(); }