C Exercises: Display the pattern like a pyramid with a number which will repeat the number in the same row
17. Pyramid Pattern with Repeated Numbers
Write a C program to make such a pattern like a pyramid with a number which will repeat the number in the same row.
The pattern is as follows:
1 2 2 3 3 3 4 4 4 4
This C program generates a pyramid pattern where each row contains repeated numbers corresponding to the row number. For example, the first row displays '1', the second row displays '2 2', and so on, up to the specified number of rows. The program uses nested loops to create the pyramid structure, with careful formatting to align the numbers correctly.
Visual Presentation:

Sample Solution:
C Code:
Output:
Input number of rows : 5 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
This C program generates a pyramid pattern where each row contains repeated numbers corresponding to the row number. For example, the first row displays '1', the second row displays '2 2', and so on, up to the specified number of rows. The program uses nested loops to create the pyramid structure, with careful formatting to align the numbers correctly.
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C program to display a pyramid where each row repeats its row number and then print the sum of each row.
- Write a C program to display a pyramid pattern with repeated numbers, alternating the order for even-numbered rows.
- Write a C program to generate a pyramid of repeated numbers using recursion.
- Write a C program to print a pyramid of repeated numbers and calculate the total sum of all numbers in the pyramid.
C Programming Code Editor:
Previous: Write a program in C to display the n terms of even natural number and their sum.
Next: Write a program in C to find the sum of the series [ 1-X^2/2!+X^4/4!- .........].
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics