title: in the c++ hacker rank preperation cause, the last index returns 0 when i reverse it. but when i try the code out in visual studio, it works perfectly
body: <p><strong>HERE IS THE QUESTION I FACED ON HACKERRANK.</strong></p>
  <p><a href="https://i.stack.imgur.com/0CLPp.png" rel="nofollow noreferrer">the hackerrank question</a></p>
  <p><strong>HERE IS THE CODE I PRINTED</strong></p>
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  
  int main() {
      int n;
      int array[n];
      int c,x;
      
      cin&gt;&gt;n; //inputting the array size
      n=n+1;
      int m=n;
      if(n&gt;=1 &amp;&amp; n&lt;=1000 &amp;&amp; m&gt;=1 &amp;&amp; m&lt;=1000 )
      {
          for(c=1;c&lt;=n;c++)//inutting the numbers
          {   if(c&lt;=10000)
              {
                  cin&gt;&gt;array[c];            
              }
      
          }
          
          for(x=m-1;x&gt;=1;x--)//outputing the numbers reversed
          {
              cout&lt;&lt;array[x]&lt;&lt;&quot; &quot;;
          }        
      }
      
      return 0;
  }
  </code></pre>
  <p>WHEN I GIVE INPUT THE ARRAY SIZE AS 4 AND THE DATA AS 1 4 3 2,
  <strong>ITS REVERSED AS 2,3,4,0</strong>
  BUT IT PERFECTLY GETS REVERSED WHEN COMPILED WITH VISUAL STUDIO CODE. WHYS THAT?? AND ALSO WHEN I SUBMIT CODE SEVERAL TESTS PASS, BUT SOME GET A SEGMENTATION ERROR</p>