My code will compile, but will not populate the table, or it runs an infinite loop. This version shows the empty table. The infinite loop happens when i move the fallDistance function outside of the for loop. I thought it needed a while loop since the value of seconds and meters weren't determined.
My textbook is only pseudocode, the C++ Language Companion is very sparse. I have 3 C++ books I have been consulting for, oh gee, let's say the last 6 hours.
Please help me find where it is out of sequence or whatever I've done wrong. This is the first problem using srand(), time(0, and the #include <cstdlib> and #include <ctime>
Line 44: I'm guessing this is a leftover from the while loop. seconds will iterate twice as fast because of that line, and I don't think you wanted that.
Line 58: This is the cause of your infinite loop. You're resetting seconds to 0, but seconds being greater than 10 is the condition for your loop to end.
Line 38: Using range seems a lot more straightforward. I have only used it in Javascript. It's good to know you can use it in C++. I think we are supposed to follow the chapter example though. -- left all of that in there
Line 44: I copied that from the Celsius to Fahrenheit program I had written for another assignment because I thought that may have been a missing piece. -- took that out
Line 58: I set the seconds to 10, that only displayed 10. I renamed the variables of the function and that made it display correctly but only 1 second. Then I uninitialized those variables and it worked!
The program is to calculate how far (in meters) a star falls per second ( ranging from (1-10 seconds). I should start writing that at the top.