Scope of A Variable
Remember : when you declare a variable inside a
for-loop, the scope of that variable ends when the
for statement does. This program won’t compile,
because the variable i exists only inside the for-loop.
void main()
{ for (int i = 0; i < 7; i++)
{ cout << i << endl;
}
cout << i << endl;
}