Write a program in which there is a global variable, a local variable for main function and a variable in a nested scope inside main, with the same name. Print all the three variables.
#include<iostream>
using namespace std;
int x =5; //Global variable
int main(){
	cout<<"The variable value is : "<<x<<endl;
	int n=4;
	if(n==4){
		x = 10;
			cout<<"The variable value is : "<<x<<endl;
	}
	x=40;
		cout<<"The variable value is : "<<x<<endl;
}
Comments
Thanks a ton AssignmentExpert