Returning

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

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: Returning

 
0
  #21
Feb 28th, 2008
#include <iostream>
#include <cstdlib>
using namespace std;

// Put you function prototype (declarations) here.



double MPG ( double sizeoftank, double numberofmilest, double gasleftintank)
{


MPG=numberofmilest/(sizeoftank-gasleftintank);
return MPG;
}

system("PAUSE");

}
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 66
Reputation: superjacent is an unknown quantity at this point 
Solved Threads: 3
superjacent's Avatar
superjacent superjacent is offline Offline
Junior Poster in Training

Re: Returning

 
0
  #22
Feb 29th, 2008
You need to at least write a main() program, that is the only way you will be able to test your mpg function.
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: Returning

 
0
  #23
Feb 29th, 2008
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. // Put you function prototype (declarations) here.
  6.  
  7.  
  8. int main ()
  9. {
  10.  
  11.  
  12. }
  13. double MPG ( double sizeoftank, double numberofmilest, double gasleftintank)
  14. {
  15.  
  16.  
  17. double MPG=numberofmilest/(sizeoftank-gasleftintank);
  18. return MPG;
  19. }
  20.  
  21. system("PAUSE");
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 66
Reputation: superjacent is an unknown quantity at this point 
Solved Threads: 3
superjacent's Avatar
superjacent superjacent is offline Offline
Junior Poster in Training

Re: Returning

 
0
  #24
Feb 29th, 2008
You still need to call your function from main(). In main, simply initialise and assign three double variables and pass them into your function.

In main() something like this cout << mpg(d1, d2, d3) << " mpg.\n"; Note, d1, d2 & d3 are the three variables previously initialised and assigned.

We're not bothered about user input at this stage, the whole point is merely to test that your functions works. I can tell you that your function is correct but you need to test it for yourself.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1984 | Replies: 23
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC