Im just think about this and could be wrong but try putting the int x out of the for loop and use and int i in the for loop instead: like this


int x;
for(int i; i<20;i++)
{
...