C-programming - Global variables, C++ global variables
Global variables
Global Variable
Variables declared outside of a block are called global variables. Global variables have program scope, which means they can be accessed everywhere in the program, and they are only destroyed when the program ends.
#include <iostream.h>
float pi = 3.14;
int circlearea()
int area,r;
r=10
area= pi*r*r;
cout<< "area of circle: " << area << '/n';
int circlecircum()
int circum, r;
r=10;
circum= 2*pi*r;
cout<< " circumference of circle: " << circum << '/n';
int main( )
{
circlearea();
circlecircum();
return 0;
}
output
area of circle: 314 circumference of circle:62.8
The topic on C-programming - Global variables is posted by - Sathya
Hope you have enjoyed, C-programming - Global variablesThanks for your time