7.Write a C++ program to use scope resolution operator. Display the various values of the same variables declared at different scope levels.
#include <iostream>
#include<conio.h>
using namespace std;
int x;
int main() {
int x = 10; // Local x
cout << "\nValue of global x is " << ::x;
cout << "\nValue of local x is " << x <<endl;
return 0;
}
Output:
0 Comments