title: How do I use variables across multiple functions?
body: <p>Suppose I have a simple console program as follows:</p>
  
  <p>(haven't tested it and it may contain errors since I'm sort of a newbie)</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  void startProgram();
  
  int main(){
  a = 20; //I want to somehow set this so that I can use it in any other function
  //without passing it through like startProgram(a);
  
  startProgram();
  return 0;
  }
  
  void startProgram(){
  cout &lt;&lt; a &lt;&lt; endl;
  }
  </code></pre>
  
  <p>So... How do I make it so that I can change the value of 'a' or print it or do whatever without passing it through to every function?</p>
  
  <p>And sorry if there are questions like this already, which I don't doubt, but I couldn't find any!</p>
  
  <p>Thanks in advance!</p>