Unit 3 Chapter 1 Assessment #16


Question 16
The question says i<15
When you count out the lines in option B there are 15 of them. Shouldn’t there only be 14?
Or is the function starting on 0?


It runs 15 times. So, yes, that means that the first time through the loop i=0. Second time i=1. and so on. The loop condition runs for i=0 up to i<15 which means 0 to 14…which is 15 things.

A common pattern in programming is to start counting with 0 rather than 1. This means you often see things like: for( i=0; i<15; i++) and you learn to read that as a loop that runs 15 times.