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.

Recommended Answers

All 3 Replies

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

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;
}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.