+ 8
What is the output?
int i=5; for(int i=0; i<7;i++){ } cout<<i;. //answer is 5 why not 7?
4 ответов
+ 11
5. Because the loop variable i is declared inside the loop and can only be accessed within the loop. So when you are trying to access i outside the loop, it will refer the first i which was declared outside.
+ 6
thank you so much shamima and naitomea
+ 4
It should be 5, because the 'i' in the for-loop has only a local range and won't affect the 'i' declared in main function.
+ 3
Devendra Yadav
https://code.sololearn.com/c2PPaDf6q48j/?ref=app