Global variables in C++
How Global variables are used in C++?
Variables that are declared outside the scope of a function, so that it can be used anywhere in the program is known as Global Variables
float pi = 3.14;
int main( )
rad = 100;
area = pi*rad*rad;
cout << "Area of a Circle:" << area << '\n';
Area of a Circle: 31400
In the above example "pi" is declared as global variable outside any function. But the "pi" value is used inside the main function.