C++ Programming/Scope/Examples/Complicated Scope Program2
From Wikibooks, the open-content textbooks collection
< C++ Programming | Scope | Examples
// Complicated Scope Program, variation 2 #include <iostream> using namespace std; /* outermost level of scope starts here */ int i; main(){ /* next level of scope starts here */ int i; i = 5; for( /* next level of scope starts here */ int i = 1; i<10 && cout << i << ' '; ++i ) { /* next level of scope starts here */ int i = -1; cout << i << ' '; } /* two levels of scope end here*/ cout << i << endl; } /* next and outermost levels of scope end here */