Cleanup Problem Runtime Error

I am getting a runtime error for the cleanup problem. I don’t know, please help:

#include <iostream>
using namespace std;

int main()
{
int q,totno,nocomp,a[10],i=0,j=0,temp=0;

cin>>q;
do
{
cin>>totno>>nocomp;
for(i=0;i<nocomp;i++)
{
cin>>a[i];
}

for(i=0;i<nocomp;i++)
{
for(j=0;j<nocomp;j++)
{if(a[i]>a[i+1])
{temp=a[i+1];
a[i+1]=a[i];
a[i]=temp;
}
}
}

for(i=0;i<nocomp;i++)
{cout<<a[i]<<" ";
i+=1;
}
for(i=1;i<nocomp;i++)
{cout<<a[i]<<" ";
i+=1;
}
--q;
}while(q>=0);
return 0;
}

while(q>=0);

I think this is the reason. You are iterating an extra iteration. Lets say i enter 5, meaning i want output of 5 test cases. How will this do while loop execute then?

5-Execute
4-Execute
3-Execute
2-Execute
1-Execute
0-Execute

It is executing an extra time, but input is only for 5 test cases. This leads nocomp to get a garbage value, which leads to runtime error when you declare an array using it, or attempt to loop through the array with condition (infinite loop- would have given TLE BUT array index out of bound happens before TLE could happen resulting in run time error).