Well the easiest thing to do would be to just put the above code in a function:
Code:
void printMenu(){
cout << "************************" << endl; //menu for options
cout << "* A - Addition *" << endl;
cout << "* B - Subtraction *" << endl;
cout << "* C - Multiplication *" << endl;
cout << "* D - Division *" << endl;
cout << "* E - Random problems *" << endl;
cout << "* F - Quit *" << endl;
cout << "************************" << endl;
}
That won't return the menu, but it will display it whenever you call the fucntion.
You can also make the menu text a constant string that the function returns:
Code:
const char *menu(){
static const char *const menuText =
"************************\n"
"* A - Addition *\n"
"* B - Subtraction *\n"
"* C - Multiplication *\n"
"* D - Division *\n"
"* E - Random problems *\n"
"* F - Quit *\n"
"************************\n";
return menuText;
}
Here you can use string instead of char *, although in this particular case char * works just as well. Also, note that writing adjacent strings like that is equivalent to writing one long string.