Hello all, Sorry for the newbie post but I am trying to complete an assignment. My code does for the most part what the assignment asks.
My code should compile a program that computes how many meters an object falls in 1 second, 2 seconds, etc., up to 10 seconds.
Entering data either under 1 or over 10, spins this into an infinite loop and even though it is re-prompting for a new integer, it does ask, but it loops at that point.
#include <iostream>
#include <cmath>
using namespace std;
//main function
int main()
{
int runningCount = 1;
int time = 0;
double FallingDistance(time);
cout << "Please enter a time between 1 and 10 seconds.\n\n";
cin >> time;
while ( time < 1 || time > 10)
{
cout << "Must enter between 1 and 10 seconds, please re-enter.\n";
while ( time < 1 || time > 10)
{
cout << "Must enter between 1 and 10 seconds, please re-enter.\n";
}
You tell the user to re-enter the time, but never actually ask the user for anything again. The loop is entered, and the time variable is never changed, so it runs infinitely.