| | |
Returning
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
•
•
double MPG ( double sizeoftank, double number of milest, double gasleftintank)
{
double numberofmilest;
numberofmilest=sizeoftank/gasleftintank;
return numberofmilest;
}
Done
I have not run the function in a program, its the freaking math of this thats pissing me off, this shit is frustrating
•
•
Join Date: Jan 2008
Posts: 124
Reputation:
Solved Threads: 1
double MPG ( double sizeoftank, double number of milest, double gasleftintank)
{
double numberofmilest;
sizeoftank=numberofmilest/gasleftintank;
return sizeoftank;
}
i switched the bolded statement around if miles/gallon will yeild mpg then I guess this is right...let me rephrase that I hope this is right....
{
double numberofmilest;
sizeoftank=numberofmilest/gasleftintank;
return sizeoftank;
}
i switched the bolded statement around if miles/gallon will yeild mpg then I guess this is right...let me rephrase that I hope this is right....
Ok, I can see where you are confused and I apologise accordingly. I re-read your initial first post and I skipped the bits about the information to be input being 1. size of tank, 2. gallons left and 3. miles travelled. I assumed (lesson never assume) that gallons used was inputted directly. In that regard, yes, there are three (not two as I previously mentioned) arguments to be passed into the function. In the function simply deduct gallons left from size of tank and that equals gallons used. From there it's a straight out mpg calculation.
Last edited by superjacent; Feb 28th, 2008 at 9:56 pm. Reason: spelling.
•
•
•
•
how would I go about using three agruments to yield the number of miles a car can travel with one gallon of gasoline
miles travelled / (size of tank - gallons left) = mpg.
mpg is miles per gallon.
miles : 1000
size (gallons) : 60
left (gallons) : 10
1000 / (60-10) = 20 mpg.
•
•
Join Date: Jan 2008
Posts: 124
Reputation:
Solved Threads: 1
C++ Syntax (Toggle Plain Text)
double MPG ( double sizeoftank, double numberofmilest, double gasleftintank) { mpg=numberofmilest/(sizeoftank-gasleftintank); return mpg; }
Last edited by Jboy05; Feb 28th, 2008 at 10:22 pm.
•
•
•
•
C++ Syntax (Toggle Plain Text)
double MPG ( double sizeoftank, double numberofmilest, double gasleftintank) { mpg=numberofmilest/(sizeoftank-gasleftintank); return mpg; }
![]() |
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 array arrays based binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





