Skip to content

Instantly share code, notes, and snippets.

@dibakarsutradhar
Created September 14, 2018 17:14
Show Gist options
  • Save dibakarsutradhar/e44a3bf623cd271f9a4c2962d27fd43f to your computer and use it in GitHub Desktop.
Save dibakarsutradhar/e44a3bf623cd271f9a4c2962d27fd43f to your computer and use it in GitHub Desktop.
#include <iostream>
// global variables
int global = 10;
void globalDisplay() {
// global variable accessed from within a function
std::cout << global << std::endl;
}
// main function
int main() {
globalDisplay();
// changin the value of global variables
global = 5;
globalDisplay();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment