title: Global variables in C++
body: <p>I am supposed to write a program that should read from input numbers in the main() part, and then make some calculations in other bool functions. I don't want to insert the whole arrays of the numbers and all the other parameters in the functions everytime i call them. </p>
  
  <p>My question is this: Can i make somehow in c++ to read input in some variables, but in a way that other functions outside of main() will also "know" this variables and what's inside them so i don't have to put a lot of arguments when i call the functions ?</p>
  
  <p>This is the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  inline bool del(int n)
  {
      int i;
      for(i=0;i&lt;s1;i++)
      {
          if((n % a[i]) == 0) return true;
      }
      return false;
  }
  inline bool ned(int n)
  {
      int i;
      for(i=0;i&lt;s2;i++)
      {
          if((n % b[i]) != 0) return true;
      }
      return false;
  }
  int main(void)
  {
      int s1, s2, a[25], b[25];
          int m, n, i, k=0;
      bool d, nd;
      cin &gt;&gt; s1 &gt;&gt; s2 &gt;&gt; m &gt;&gt; n;
      for(i=0;i&lt;s1;i++)
          cin &gt;&gt; a[i];
      for(i=0;i&lt;s2;i++)
          cin &gt;&gt; b[i];
      for(i=m;i&lt;=n;i++)
      {
          d = del(i);
          nd = ned(i);
          if(d == true &amp;&amp; nd == true) ++k;
      }
      cout &lt;&lt; k &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>int s1, s2, a[25], b[25] &lt;- These are the vars i need to be seen by the other functions (because i use them as you can see). </p>
  
  <p>I tried declaring them like global, but that didn't work, i got errors like "was not declared in this scope" .</p>
  
  <p>Thank you for the help.</p>