title: How function is able to read the value of user input variable from main function without passing the value as param?
body: <pre><code>#include&lt;iostream&gt;
  using std::cin;
  using std::cout;
  using std::endl;
  
  void printValue(){
      int a;
      cout&lt;&lt;a&lt;&lt;&quot; is the value&quot;&lt;&lt;endl;
  }
  
  int main(){
      int n;
      cin &gt;&gt; n;
      printValue();
      return 0;
  }
  </code></pre>
  <p>Here n is taken as user input, no value is passed to printValue( ) function, now when the function is called, a is printing the same value as n.
  Output as:-
  34
  34 is the value</p>
  <p>How is this possible that a can take the value of n instead of printing a garbage value?</p>