What will be the output of the following C++ code? [code] #include <iostream> using namespace std; namespace first {

Phương Linh

New member
What will be the output of the following C++ code?
Code:
    #include <iostream>
    using namespace std;
    namespace first
    {
        int x = 5;
        int y = 10;
    }
    namespace second
    {
        double x = 3.1416;
        double y = 2.7183;
    }
    int main ()
    {
        using first::x;
        using second::y;
        bool a, b;
        a = x > y;
        b = first::y < second::x;
        cout << a << b;
        return 0;
    }
A. 11
B. 01
C. 00
D. 10
 
Answer: d
Explanation: We are inter mixing the variable and comparing it which is bigger and smaller and according to that we are printing the output.
Output:
Code:
$ g++ name1.cpp
$ a.out
10
 

Tìm kiếm

Back
Top