| | |
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
Views: 1984 | Replies: 23
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





