## Sep 8, 2020

### C program to print half right side of pyramid number pattern

#### Ex: Write a C program to print half right side of pyramid number pattern. How to write a C program to print half right side of pyramid number pattern. C program to print half right side of pyramid number pattern.

Input from user:

Enter the number: 5

Expected output:

1

12

123

1234

12345

### Step by step logic of the given program:

This pattern is same as previous exercises star pattern:

*

**

***

****

*****

Difference is:

In this pattern we only need to replace the * with value of j .

1. Accept input number from user declare variable say no.

2. Run outer for loop from 1 to no which shows rows in pattern:

for(i=1;i<=no;i++)

3. Run inner for loop from 1 to  i which shows columns in pattern:

for(j=1;j<=i;j++)

4. Inside the inner loop print value of j :

printf("%d",j);

5. For next row print \n.

## Program to print half right side of pyramid number pattern:

#include<stdio.h>

void main()

{

int no,i,j;

printf("Enter the number: ");

scanf("%d",&no);

/*Run outer loop from 1 to no*/

for(i=1;i<=no;i++)

{

for(j=1;j<=i;j++)

{

/*Print value of j*/ printf("%d",j);

}

/*For new row*/ printf("\n");

}

}

Above program shows the following output: