Pre-Christmas sale Swift week
Save up to 80 % on Swift e-learning! Only this week!
Christmas are almost here! Get up to 20 % extra points for free! More info

Discussion: For loop not working properly

Activities (4)
Avatar
Paul Michaels
Member
Avatar
Paul Michaels:11/11/2016 13:56

I get that for loops run through a set amount of iterations, but mine's not working. What am I doing wrong?

for (int i; i < 3; i++)
{
        Console.WriteLine("Knock");
}
Console.WriteLine("Penny!");
Console.ReadKey();
                }
        }
}
 
Reply 11/11/2016 13:56
Avatar
Replies to Paul Michaels
Matthias Quintero:11/11/2016 14:12

You never initialized the iteration counter, so the loop starting point is undefined.

 
Up Reply 11/11/2016 14:12
Avatar
Paul Michaels
Member
Avatar
Paul Michaels:11/11/2016 14:13

Thank you! It works now

 
Up Reply 11/11/2016 14:13
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

3 messages from 3 displayed.