| | |
Returning
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
You need to at least write a main() program, that is the only way you will be able to test your mpg function.
•
•
Join Date: Jan 2008
Posts: 124
Reputation:
Solved Threads: 1
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <cstdlib> using namespace std; // Put you function prototype (declarations) here. int main () { } double MPG ( double sizeoftank, double numberofmilest, double gasleftintank) { double MPG=numberofmilest/(sizeoftank-gasleftintank); return MPG; } system("PAUSE");
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
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.
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.
![]() |
Similar Threads
- Searches only returning results for certain strings (PHP)
- Returning Empty Datatable (ASP.NET)
- Table query returning error -- help! (MS SQL)
- Regarding Function Returning a Value. (C)
- Exact meaning of functions returning reference (C++)
- returning by reference (C)
- returning an array? (C++)
- Returning a correct python list (Python)
Other Threads in the C++ Forum
- Previous Thread: Why wouldn't this work?
- Next Thread: Combinations of Inheritance and Composition
| Thread Tools | Search this Thread |
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib library linkedlist linker list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings studio temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





