Question: This is for C++: I am writing a function that requires me to store data into a 2D array. I cannot figure out how to
This is for C++:
I am writing a function that requires me to store data into a 2D array. I cannot figure out how to store the values that I obtain for the velY or the posY into the array. Here's what I have so far:
void Function(double velocity, double angle, double position[SIZE][2], int& total) { double posX{ 0.0 }, posY{ 0.0 }, velX{ 0.0 }, velY{ 0.0 }, degree{ 0.0 }, radian{ 0.0 };
int counter{ 0 };
angle = angle * PI / 180;
velX = vel0 * cos(angle);
velY = vel0 * sin(angle); //Open a while loop do { Move(velX, velY, &posX, &posY);
posX = posX;
posY = posY;
velY = velY - G * DELTA_T; counter++;
cout << "Height: " << posY << " meters" << endl << "Distance: " << posX << " meters" << endl; } while (posY >= 0 && counter < SIZE);
}
Any tips would be great! Thanks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
