Friday, March 3, 2017

How for loop works in programming language?

How for loop works in programming language?

Working of for loop

A for loop is used to repeat a specific block of code number of times. For example, you want to print a table for 2, 3, 4 or so on, or you want to print prime numbers between 1-1000 and if you want to check the grades of every student in a class. So, here we use loops. And for loop is one of the mostly use loop among the others (while loop and do while loop).
The advantage of for loop is you know exactly how many times the loop will execute before the loop starts.