accessing an array
<p>i am declaring a global array,and then assigning the values inside a if statement. But when i am using the array in another if statement the array has different values other than i assigned previously.
For example:</p>

<pre><code>int arr[5];
xyz(bool p,bool q)
{
    if(p)
    {
        for(int i=0;i&lt;5;i++)
        {
            arr[i]=rand()%100;
        }
    }

    if(q)
    {
        for(i=0;i&lt;5;i++)
        printf("%d",arr[i]);
    }
}
</code></pre>

<p>can anyone help??</p>
