C++ examples for Function:Global Variable
Uses both local and global variables.
// Local Variables Global Variables // j, p i, z #include <iostream> using namespace std; int pr_again(); // Prototype int i = 0; // Global variable because it's defined outside main(). int main()//from w w w.jav a 2 s . c om { float p ; p = 9.0; cout << i << ", " << p << "\n"; pr_again(); return 0; } float z = 9.0; int pr_again() { int j = 5; cout << j << ", " << z; cout << ", " << i << "\n"; return 0; }