+ 1
[SOLVED] What does "2" in this for expression want to tell us?
for (int value = 2; value <= max_value; value++)
4 Answers
+ 1
It's ok. I'll try my best to explain.
You are surely familiar with this
for(int value = 1; value <= max_value; value++)
or
for(int value = 0; value <= max_value; value++)
As you already know this is a foor loop. What it does is, it executes the code inside it untill the condition in the second part (value <= max_value) is met and third part tells what to do to the value variable each loop.
So if first part was int value = 1; and second part was value <= 5; then code will execute 5 times.
If first part was int value = 2; and second part was value <= 5; then code will execute 4 times.
+ 2
number 2 is the intial value for the variable "value"
https://code.sololearn.com/cozGnau36rEn
Please try it yourself, with pratice and coding
+ 2
As sneeze said, it seems that the answer to your question is within the question itself. What is confusing you?