Can somebody solve this problem using nasted loops in c++ ?it's crashing my mind!
Out put: 1 2 3 4 0 2 4 1 3 0 3 1 4 2 0 0 1 2 3 4 Here's my attempt but it doesn't shows the same out put as i want and i know it could be solved using nasted loops #include <iostream> using namespace std; int main() { for(int j=1;j<=4;j++) { { if (j==1) { for(int l=1;l<=4;l++) cout<<l<<"\t"; cout<<"0\n"; } else if (j==2) { for(int q=1;q<=4;q++) if (q%2==0) cout<<q<<"\t"; for(int l=4;l>=1;l--) if (l%2!=0) cout<<l<<"\t"; cout<<"0\n"; } else if (j==3) { for(int q=1;q<=4;q++) if (q%2!=0) cout<<q<<"\t"; for(int l=1;l<=4;l++) if (l%2==0) cout<<l<<"\t"; cout<<"0\n"; } if (j==4) { cout<<"0\t"; for(int q=1;q<=4;q++) cout<<q<<"\t"; } } } }