Completing User defined function

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jan 2008
Posts: 124
Reputation: Jboy05 is an unknown quantity at this point 
Solved Threads: 1
Jboy05 Jboy05 is offline Offline
Junior Poster

Completing User defined function

 
0
  #1
Mar 4th, 2008
Consider the following two function prototypes:

void Func1(int&, int&); int Func2(double, double);


-I need help completing the following C++ user-defined function Func3
-which prompts and gets an integer for the variable Option from user.
-Func1 should be called when the value of Option is 1,
- Func2 should be called when the value Option is 2, the message "Wrong Selection. " should be displayed if the user had entered anything other than 1 or 2.


  1. int Func3 ()
  2. {
  3. int Option;
  4. int A = 2;
  5. int B = 3;
  6. double C = 2.5;
  7. double D = 3.5;
  8. cout << " Enter your select: ";
  9. cin >> Option;
  10.  
  11.  
  12. }
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 62
Reputation: Joatmon is an unknown quantity at this point 
Solved Threads: 7
Joatmon Joatmon is offline Offline
Junior Poster in Training

Re: Completing User defined function

 
0
  #2
Mar 4th, 2008
pseudo-code follows:

....
get option
while option isn't 1 or 2
display "Bad option selection, re-enter it: "
get option
end while
if option is 1
call func1 with A and B
if option is 2
call func2 with C and D
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 124
Reputation: Jboy05 is an unknown quantity at this point 
Solved Threads: 1
Jboy05 Jboy05 is offline Offline
Junior Poster

Re: Completing User defined function

 
0
  #3
Mar 4th, 2008
please help
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 978
Reputation: mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice 
Solved Threads: 208
mitrmkar mitrmkar is offline Offline
Posting Shark

Re: Completing User defined function

 
0
  #4
Mar 4th, 2008
  1. int Func3 ()
  2. {
  3. int Option;
  4. int A = 2;
  5. int B = 3;
  6. double C = 2.5;
  7. double D = 3.5;
  8. cout << " Enter your select: ";
  9. cin >> Option;
  10.  
  11. if(1 == Option)
  12. {
  13. // Call func1() here
  14. }
  15. else if(2 == Option)
  16. {
  17. // Call func2() here
  18. }
  19. else
  20. {
  21. cout << "Wrong selection ...\n";
  22. }
  23.  
  24. // return some value here ...
  25. return 0;
  26. }
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC