simple function question

I'm confused on what type of function declaration I would use to get the correct output for this program. I understand I would need to write a function, but would it be a for loop?


/*
Program: repair2a: this program prompts for the the velocities (v0, v1) of two approaching
vehicles and their distance (d) apart,
then displays the time they meet and the distance each travels.
Example:
If d is 100, v0 is 75, and v1 is 25,
time is 1.00, distance0 is 75.000, distance1 is 25.00
If d is 151.5, v0 is 65.2, v1 is 42.8,
time is 1.403, distance0 is 91.141, distance1 is 60.039
Add the missing first line of the function and add the function declaration
DO NOT make any other changes
DO NOT us unnecessary refernce parameters
*/

#include <iostream>
#include <iomanip>
using namespace std;

//Function Declaration goes here


int main(void)
{
double d, v0, v1, time, distance0, distance1;

cout << "Enter d, v0, v1: ";
cin >> d >> v0 >> v1;

meet(d, v0, v1, time, distance0, distance1);

cout << fixed << setprecision(3);
cout << "Time is " << time << " distance0 is " << distance0
<< " distance1 is " << distance1 << endl;

return 0;
}


// First line of the function goes here
{
time = d / (v0 + v1);
dist0 = v0 * time;
dist1 = v1 * time;
}
I think this problem isn't asking you to write the function — they already have the function (see the bottom of the program), you just need to give it the correct declaration. By declaration, I mean the bit that identifies the name of the function, what it returns, and what parameters it takes.

Here are a couple of examples of function declarations:
1
2
int main();
void doSomething(double x, int* y, char& z);
closed account (48T7M4Gy)
I think that's your job as part of the repair assignment. BTW a function declaration and for loop are two different things. Maybe read your notes?
Topic archived. No new replies allowed.