1. Create a new project with following particulars
1. name the project title in the following format “ID_section_lab#” e.g., “f2019065111_w1_lab2”.
2. Create a menu to execute tasks. There shall be n tasks in total, update as they comes up. You should properly prompt wherever necessary. A sample menu is shown below.
using namespace std;
#define NO_OF_TASKS 4
int main()
{
float a,b,c;
int i,Flag=1;
while(Flag)
{
cout<<"\nPress 1 for Task-1 (Addition)";
cout<<"\nPress 2 for Task-1 (Substraction)";
cout<<"\nPress 3 for Task-1 (Multiplication)";
cout<<"\nPress 4 for Task-1 (Division)";
cout<<"\nPress 0 to QUIT";
Flag=-1;
while(Flag<0 || Flag>4)
{
cout<<"\nEnter Option (0 to 4): "; cin>>Flag;
}
cout<<"\nEnter first number a = "; cin>>a;
cout<<"\nEnter second number b = "; cin>>b;
switch(Flag)
{
case(1): c = a+b; cout<<"\nResult = "<<a<<" + "<<b<<" = "<<c; break;
case(2): c = a-b; cout<<"\nResult = "<<a<<" - "<<b<<" = "<<c; break;
case(3): c = a*b; cout<<"\nResult = "<<a<<" * "<<b<<" = "<<c; break;
case(4): c = a/b; cout<<"\nResult = "<<a<<" / "<<b<<" = "<<c; break;
case(0): break;
}
}
}
Comments
Leave a comment