What is the output of the following C++ program? #include <iostream> using…

What is the output of the following C++ program?

#include <iostream>
using namespace std;
int x = 10;
void fun() {
    int x = 2;
    {
        int x = 1;
        cout << ::x << endl;
    }
}
int main() {
    fun();
    return 0;
}
  1. A.

    1

  2. B.

    2

  3. C.

    10

  4. D.

    error

Attempted by 271 students.

Sign up free to check your answer

Sign up free

Explore the full course: Isro

Loading lesson…