/*
use of global variable, all functions can access to it.
numeric global variable is initialized to 0 automatically,
character global variable is initialized to NULL automatically
*/
#include <iostream>
using namespace std;
void anotherFunction();
int num = 2;
int main()
{
cout << "In main, num is " << num << endl;
anotherFunction();
cout << "Back in main, num is " << num << endl;
return 0;
}
void anotherFunction()
{
cout << "In anotherFunction, num is " << num << endl;
num = 50;
cout << "But, it is now changed to " << num << endl;//change the num to 50, and return it because it is global variable
}