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;
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);