Answer:
I have added the code again with the mistakes are corrected please see the comments in code. You have mistake in while loop condition.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int options ();
int option1 ();
int option2 ();
int option3 ();
double addition (double num1, double num2);
double multiplication (double num1, double num2);
int main()
{
jump:
int option = 0;
cout << "1. Add" << endl;
cout << "2. Multiply" << endl;
cout << "3. Exit" << endl;
cout << "Enter option 1 for addition, option 2 for multiplication, or option 3 to exit" "Enter an option: ";
cin >> option;
switch (option)
{
case 1:option1;
int option1 ();
{
double num1 = 0;
double num2 = 0;
// void int key = 0;
cout << " Enter a number: ";
cin >> num1;
cout<< " Enter a second number: ";
cin >> num2;
double sum = addition(num1, num2);
cout << " Sum is: " << sum <<endl;
} break;
case 2: option2;
int option2 ();
{
double num1 = 0;
double num2 = 0;
cout << " Enter a number:";
cin >> num1;
cout << " Enter a second number: ";
cin >> num2;
double product = multiplication(num1, num2);
cout << " Product is: " << product << endl;
//system("cls");
}
break;
case 3: option3;
int option3();
{
return 0;
}
break;
default: cout << " Invalid number entered: ";
}
//do {main();}
//while (option < 3); //you have mistake in this loop please have a look
while (option<3)
{
goto jump;
}
}
double addition(double num1, double num2)
{
return num1 + num2;
}
double multiplication(double num1, double num2)
{
return num1*num2;
}
Explanation:
You can also do this by using goto statement in switch case and menu will be repeated until the user not select to exit and now it will work with the loop as well.
I hope it will help you!