For example, you are given an integer n(at compile time). Your task is to creat n nested loops with distinct loop control variables(array[0],array[1]. i,j,k...) and under the scope of all loops, execute statements like :cout<<"Hello, World"<<endl
and make the possibility to use all loop control variables(So that logic using loop control variables can be designed).Along with n, other informations like initial value and condition for i'th(0 to n) loop control variable could be provided.Our objective should be to make the process flexible and generic. Is it possible in C or C++ or Java or ....(Popular Programming Languages) ?
A C++ code for n = 3 could be :
for(int i = 0; i<n; i++)
{
for(int j = 0; j<n; j++)
{
for(int k = 0; k<i+j; k++)
{
cout<<i*j+k<<endl;
}
}
}
For n=4, it could be
for(int i = 0; i<n; i++)
{
for(int j = 0; j<n; j++)
{
for(int k = 0; k<i+j; k++)
{
for(int l = 0; l<k+3; l++)
{
cout<<i*j+k-l<<endl;
}
}
}
}