Question: I'm trying to create a C program that prints a triangular pattern according to height by only using 1, 2 and 3 to generate the patterns:

```
Enter the height:
7
Pattern:
1
22
333
1111
22222
333333
1111111

```

I am only able to print the numbers but I do not know how to print only using 1, 2 and 3

This is my code so far:

```
printf("Enter the height: \n");
scanf("%d", &height);

if(height <0 || height > 10){
    printf("Please enter height within 1 to 10!");
}
else{
    printf("Pattern: \n");

    for(row=1; row<=height; row++){
        for(int col=1; col<=row; col++){
             printf("%d", row );
        }
        printf("\n");
    }
return 0;
}

```

The output:

```
Enter the height:
7
Pattern:
1
22
333
4444
55555
666666
7777777

```

Thank you

Answer: 
Just change your print statement like,

```
printf("%d", (row % 3) > 0 ? row % 3 : 3);

```
```
#include<stdio.h>
#include<conio.h>

int main(){

    int n; int l=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int j=i;
        while(j!=0){
            printf("%d",l);

            j--;
        }
         l++;
            if(l==4){
                l=1;
            }
       printf("\n");    
    }

}

```