- Write a program in C to print right triangle having same number in a row.

**SAME NUMBER ROW TRIANGLE**

#### Required Knowledge

**Algorithm to print triangle pattern having same number in a row using for loop**

- Take the number of rows(N) of right triangle as input from user using scanf function.
**Number of integers in K**.^{th}row is always K- We will use two for loops to print right triangle of natural numbers.
- Outer for loop will iterate N time. Each iteration of outer loop will print one row of the pattern.
- For K
^{th}row, Inner loop will iterate K times. Each iteration of inner loop will print row number on screen.

## C program to print right triangle pattern having same number in a row

#include<stdio.h> int main() { int i, j, rows; int count = 1; printf("Enter the number of rows\n"); scanf("%d", &rows); for (i = 1; i <= rows; i++) { for (j = 1; j <= i; j++) { printf("%d ", i); } printf("\n"); } return(0); }Output

Enter the number of rows 5 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5

**Related Topics**