How to print pattern two triangles in c that are on the same plane and attached with their base? [refixed coder]

To print this pattern in the correct format, you should follow some steps.

refixed coder

1. for loop

2. nested for loop

3. print '*' exact particular position.

4. If no. of the digit in any line is one, then you should not print '*' at that particular line.

5. you have to use nested loops for two times.

PATTERN FORMAT:

1

2*2

3*3*3

4*4*4*4

5*5*5*5*5

5*5*5*5*5

4*4*4*4

3*3*3

2*2

1


---------------

CODE:

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    for (int i = 1i <=ni++)
    {
        for (int j = 1j<=ij++)
        {
            
            printf("%d",i);
            if(i==1){}
            else
            {
                if(j!=i)
                printf("*");
            }
        }
        printf("\n");
        
    }
    for (int i = ni >=1i--)
    {
        for (int j = 1j<=ij++)
        {
            
            printf("%d",i);
            if(i==1){}
            else
            {
                if(j!=i)
                printf("*");
            }
        }
        printf("\n");
        
    }
    
}



--------------

OUTPUT:



--------------



Discord Server For Programmers:

From this particular day, you will get an amazing opportunity to talk with other friends who are learning code from the same position or advanced. They will help you to clear your doubt.

To join this server, click here-

Coding Zone