In this program, we are going to share a How to define global variable in C++ with an Example. If you are a beginner and want to start learning the C programming, then keep your close attention in this tutorial as I am going to share a program for How to define global variable in C++ with an Example.
Copy the below C++ program and execute it with the help of Turbo C compiler. At the end of this program, We have shared the output of this program.
using namespace std;
//defining the global variable
//defining the local variable
cout<<"local a: "<<a<<" Global a: "<<::a;
cout<<"\nlocal a: "<<a<<" Global a: "<<::a;