Sail E0 Webinar
Question


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
Options:
A .  8.31416
B .  8
C .  9
D .  compile time error
Answer: Option B

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 ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers