Question
1.
#include
2.
using namespace std;
3.
namespace first
4.
{
5.
int var = 5;
6.
}
7.
namespace second
8.
{
9.
double var = 3.1416;
10.
}
11.
int main ()
12.
{
13.
int a;
14.
a = first::var + second::var;
15.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
namespace first
4.
{
5.
int var = 5;
6.
}
7.
namespace second
8.
{
9.
double var = 3.1416;
10.
}
11.
int main ()
12.
{
13.
int a;
14.
a = first::var + second::var;
15.
cout
Answer: Option B
Was this answer helpful ?
As we are getting two variables from namespace variable and we are adding that.
Output:
$ g++ name.cpp
$ a.out
8
Was this answer helpful ?
Submit Solution