Question
1.
#include
2.
using namespace std;
3.
namespace Box1
4.
{
5.
int a = 4;
6.
}
7.
namespace Box2
8.
{
9.
int a = 13;
10.
}
11.
int main ()
12.
{
13.
int a = 16;
14.
Box1::a;
15.
Box2::a;
16.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
namespace Box1
4.
{
5.
int a = 4;
6.
}
7.
namespace Box2
8.
{
9.
int a = 13;
10.
}
11.
int main ()
12.
{
13.
int a = 16;
14.
Box1::a;
15.
Box2::a;
16.
cout
Answer: Option C
Was this answer helpful ?
In this program, as there is lot of variable a and it is printing the value inside the block
because it got the highest priority.
Output:
$ g++ name2.cpp
$ a.out
16
Was this answer helpful ?
Submit Solution