Pyramid number problem

When i enter a number greater than 5 then the pyramid is not accurate. It doesnt look like pyramid. please help me. I had practiced this code in Visual Studio code. When the number 10 enters in pyramid then it disrupts its structure. How to overcome it

Hi @Amzad-Choudhary-353751958569219,
pls share ur code code here.

#include
using namespace std;

int main()
{
int rows;//no. of rows
cin>>rows;
for(int i=1;i<=rows;i++)//Loop for rows
{
//Loop for spaces
for(int space=1;space<=rows-i;space++)
{
cout<<" ";
}
//Loop for increasing nos.
int val=i;//since each row starts with value of row(i)
for(int count=1;count<=i;count++)//Loop forincreasing i
{
cout<<val;
val++;
}
//Decreasing number start with val-2
val=val-2;
for(int count=1;count<=i-1;count++)
{
cout<<val;
val–;
}
cout<<endl;
}
return 0;
}

@Amzad-Choudhary-353751958569219
ur code is completely fine. No need to worry if pyramid is getting distorted.
since after 5 10,11,etc will get printed, the pyramid will obviosly get disrupted.
Hope dis helps.

thanks very much for the help

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.