How to run the code for multiple inputs?

how to get multiple inputs?
for eg.

int n;
cin>>n;

if i write this it will ask only single input and then it will run the code. but what if i want first input as number of test cases and second time i want user to enter number of inputs as he mentioned above in test cases. so how to make this possible?

for eg. i want to write hello world

int main()
{
int n;
cin>>n;
for(i=1;i<=n;i++)
{
cout<<“hello world”;
}

but i want to run it for multiple inputs like

for eg. input is
2—it denotes the number of test cases
3—i want loop to run 3 times and print hello world
4----loop to run 4 times and print hello world

how to solve this sir???

You can do it this way

int main()
{
int testcases;
cin>>testcases;
while(testcases--) //This will run until testcases reduces to 0
{
int n;
cin>>n; //No of times you want to print
for(int i=0;i<n;i++)
{
cout<<"Hello World";
}
}