Pattern Mountain Problem

Hi. I’m unable to print the second part of the mountain pattern. Please help!
Here’s the code:
https://ide.codingblocks.com/s/55428

Hey Shivani, you have shared the link to wrong code here, this is the code for sum of digits problem.

Hi! Sorry, I saved the code again.
Link: https://ide.codingblocks.com/s/55428
This should work

Hey Shivani, its pretty simple as
you can see there are ((n-i)*2)-1 spaces between left and right sequence so update your for loop for spaces like this

for(int k=((n-i)*2)-1;k>0;k--) {
          cout<<"  ";
  	} 

and for right half you are supposed to print the pattern in reverse order, starting it from i to 1, and in last row when j==n you are not supposed to print the number. So you can write a for loop like this for right half

for(int j=i;j>=1;j--) {
        if(j!=n)
      cout<<j<<" ";
    }
1 Like

Oh, I understood now. Thank you!