Using a for loop:
Create a 4×4 2D list that counts up from 1-16
Solution
#include <iostream>
using namespace std;
int main() {
int list[4][4],count=0;
for(int i=0;i<4;i++) // your required forloop
{
for(int j=0;j<4;j++)
{
count++;
list[i][j]=count;
}
}
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
cout<<list[i][j]<<“”;
}
cout<<endl;
}
return 0;
}
// if any doubt please comment