C++ Syntax Question:
Download Questions PDF

What are the scope rules you observed in the program?
task:c++ investigate the operation of scope rules in a program.
// variablenamescope
#include <iostream>
using namespace std;
int i = 111;
int main()
{
{
int i = 222;
{
int i = 333;
cout << \"i = \" << i << endl;
{
int i = 444;
cout << \"i = \" << i << endl;
{
cout << \"i = \" << i << endl;
}
}
}
cout << \"i = \" << i << endl;
}
cout << \"i = \" << i << endl;
return 0;
}

Answer:

i want to say Global scope(int i = 111;),Local scope (int i = 333;), and function scope (int i = 222;) but now, i\'m confused. I really don\'t understand what is this question asking me. Can somebody help me break it down

Download Basic C++ Syntax Interview Questions And Answers PDF

Previous QuestionNext Question
What OO language is best?Write a short code using C++ to print out all odd number from 1 to 100 using a for loop?