To do basic operation addition and subtraction i used switch case and shown the output in case of any problem let me know in comments.
Code:-
//including header files
#include<iostream>
using namespace std;
//main method
int main()
{
//taking input
float a,b;
//input first variable
cout<<"Enter Ist no: ";
cin>>a;
//input second variable
cout<<"Enter Second no: ";
cin>>b;
//Menu
cout<<"\nMenu\n1.Addition\n";
cout<<"2.Subtraction\n3.Exit\n";
//menu for calculation
bool loop=true;
//loop continues until valid input is given
while(loop)
{
cout<<"Enter your choice: ";
//choice input
int choice;
cin>>choice;
//switch case
switch(choice)
{
case 1://addition
cout<<"Addition: "<<(a+b)<<endl;
loop=false;
break;
case 2://subtraction
cout<<"Subtraction: "<<(a-b)<<endl;
loop=false;
break;
case 3://Exit
return 0;
default://run if other than above input is given
cout<<"wrong input Try again\n";
break;
}
}
return 0;
}
Output:-


c++ /Write a C++ program that creates a switch that adds and subtracts two numbers respectively.