Heya, guys. So I took a giant step back and decided to re-do the fundamentals of loops. I started with the While Loop. I made a successful code that asks the user to input two numbers, a Maximum number and a starting number.
Max = 50
Start = 1
The loop will add 1 each time until it reaches 50. :)
Now, what I want to do, is make it so that the starting number multiplies itself until it reaches the maximum number, but I have one small problem.
#include <iostream>
usingnamespace std;
int main()
{
int maxNumber;
int startNumber;
cout << "Hello, there! Choose a maximum number for this loop, please." << endl;
cin >> maxNumber;
cout << "Now, enter the starting number of the loop." << endl;
cin >> startNumber;
while (startNumber != maxNumber){
cout << startNumber * startNumber << endl;
startNumber ++;
}
return 0;
}
So, I put 50 as the max number, and 2 as the starting number.
Perhaps because startNumber never exactly equals maxNumber, so the loop never terminates? Try using greater than or less than instead of simple equality.