I'm having trouble writing a for loop that asks the user to input the number of seconds an object falls and the height it falls from. the program has to calculate the distance fallen for each second using the formula d=0.5*g*t2

cout << "How many seconds did ye' object fall? ";
cin >> seconds;

for(int i=0; i<seconds; i++)
{
     distance += .5 * g * pow(t, 2);
}

cout << "\nTotal distance traveled: " << distance;

This is enough to get you thinkin'. There are some obvious unanswered questions here, but it's enough for you to figure it out. Cause I just did 90% of the work for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.