Lecture 18 - loops - using WHILE instead of FOR

Hey Guys, just did some trial and error with the loops and I changed the FOR to a WHILE because Ben said they can be converted to each other but when I use WHILE, I get 9 errors throughout my code. Does anyone know a reason for this?

We would need to see your code to be able to help. Remember to use code formatting

It’s likely that when you converted it you got the format just a tiny bit wrong. They do the same thing but their formats are different. So make sure everything is in the right place. For example;

a For Loop written like this:

    for (int i = 0; i < 2; i++ ){ 
       cout << i;

would look like this as a While Loop:

    i = 0;
    while (i < 2){
        cout <<i;

Outside of formatting problems, if it ran properly as a for loop it will run as a while loop