Problems With Calling A Function

  • Thread starter Thread starter NDiggity
  • Start date Start date
  • Tags Tags
    Function
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
NDiggity
Messages
53
Reaction score
0

Homework Statement


I have to write a function that first prints a list of 6 choices, tells a user to choose one of the six choices using the number 1-6, then either return the number they chose or -99 if they chose a number less than one or greater than 6. Then, I have to call this function and if they chose a number between 1 and 6, report this number, but if they chose outside of the range, print you did not choose a stock.

The Attempt at a Solution


I have the function done. I just don't know how to go about calling it. What I have now is:

if(stockMenu() ==-99)
count<<"You did not choose a stock"
else
count<<stockMenu()

Obviously you can see the problem with this way, as the function runs twice. How can I do this?
 
Last edited:
Physics news on Phys.org
Haha I can't believe I couldn't think of that. Thanks a lot!