-2

can any one solve this, i tried no idea

A function called “menu” that displays a main menu. This function should return the choice of the user.

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by vmanes
0

Ya lots of ideas... but cant express it until you show your code...

#include <iostream>
using namespace std;

int menu (int a, int b)
{
  int r;
  r=a+b;
  system("pause");
  return (r);
}

int main ()
{
  int z;
  z = menu (5,3);
  cout << "The result is " << z<<"\n";
  system("pause");
  return 0;
}
0

A function called “menu” that displays a main menu. This function should return the choice of the user.

So, your function must:
1. Display the menu. What are the options in this program?

2. Ask the user to make a selection from the options available. Usually you will take this in as either a character or an integer

3. Return that choice value back to the caller.

How does your bit of code implement any of that?

And delete the system("pause") call - that has no business in a function like this. Or anywhere in most programs, for that matter.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.