#include
using namespace std;
int main() {
int a,i,j,k,m;
cin>>a;
for(i=1;i<=a;i++)
{
for(m=1;m<=a-i;m++)
{
cout<<" ";
}
for(k=i;k>=1;k–)
{
cout<<k;
}
cout<<endl;
}
return 0;
}
if this is the code tthen it give deried output i.e.
1
21
321
4321
but when i add another loop in between i and m i.e
for(i=1;i<=a;i++)
{
for(j=1;j<=i;j++)
{
cout<<j;
}
for(m=1;m<=a-i;m++)
{
cout<<" ";
}
then it gives me output:
1 1
12 21
123 321
12344321
rhat is the problem?