Ques. To print the trapezium pattern?

1*2*3*4*17*18*19*20
5*6*7*14*15*16
8*9*12*13
10*11

Please also comment the code down below in other languages.

In C

#include
int main(){
int n=4,num=1,i=1,space=0,k=1,number=n;
for(i=0;i<n;i++)
{
for(int j=1;j<=space;j++)
{

printf(“-“);

}
for(int m=1;m<2*n-space;m++)
{
if(m%2==0)
printf(“%s”,”*”);
else
printf(“%d”,num++);
}
printf(“%s”,”*”);
for(int l=1;l<2*n-space;l++)
{
if(l%2==0)
printf(“%s”,”*”);
else
{
printf(“%d”,k+number*number);
k++;
}
}
number–;

 

space=space+2;
printf(“\n”);
}
return 0;
}

 

In C++

#include<iostream>
using namespace std;
int main(){
int n=4,num=1,i=1,space=0,k=1,number=n;
for(i=0;i<n;i++)
{
for(int j=1;j<=space;j++)
{

cout<<“-“;

}
for(int m=1;m<2*n-space;m++)
{
if(m%2==0)
cout<<“*”;
else
cout<<num++;
}
cout<<“*”;
for(int l=1;l<2*n-space;l++)
{
if(l%2==0)
cout<<“*”;
else
{
cout<<k+number*number;
k++;
}
}
number–;


space=space+2;
cout<<endl;
}
return 0;
}