Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Sorry to hear that, you'll get the hang of it! For loops are different from while loops because while loops keep going until a condition is met (for example, while(myAppIsRunning){}) as opposed to a for loop, which usually runs a specific amount of times. So this loop
for(int i = 0; i < 10; i++){}
Will run ten times. The "int i" makes a variable to keep track of the amount of times the loop has looped. This can be used and changed inside the loop. The next thing is the logic; when the loop shpuld stop. In this example, when i is 10, the loop will exit. Lastly, you iterate (add one to the counter) inside the for loop declaration instead of inside the loop itself. So i++ adds one to i every time thr loop goes through. This is the general format of a loop, what language are you using? c?
I am a student from IADT and I do not understand for loops and think that I failed my programming test
undefined