Start simple. Use it to print hello world 7000 times.
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
usingnamespace std;
int main()
{
int i = 7000;
while(i > 0)
{
cout << i << ". Hello world | ";
i --;
}
}
And that's 6996 lines of code that you did not have to type.
Next try to apply it to code that you've already written that you think had things that were somewhat repetitive. The variable i is called a sentry variable and when it reaches the condition that we put in the while() argument, it will break the loop and the program continues from where it exits.
Really just start using loops in small ways and you'll pick it up pretty quickly from there.
There are a couple of loop types, but get comfortable with while() before moving on to the others.