Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std
3.
namespace space
4.
{
5.
int x = 10;
6.
}
7.
namespace space
8.
{
9.
int y = 15;
10.
}
11.
int main(int argc, char * argv[])
12.
{
13.
space::x = space::y =5;
14.
cout
Options:
A .  1015
B .  1510
C .  55
D .  compile time error
Answer: Option C

We are overriding the value at the main function and so we are getting the output as 55.
Output:
$ g++ name4.cpp
$ a.out
55



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers