- Write a program in C to print natural numbers in right triangle of n rows.
- How to print a right triangle of natural numbers using for loops.
- C program to print numbers from 1 to 10 in right triangle pattern.

**NATURAL NUMBER TRIANGLE**

#### Required Knowledge

**Algorithm to print natural number right triangle pattern using for loop**

- Take the number of rows(N) of right triangle as input from user using scanf function.
**Number of integers in K**. 1^{th}row is always K^{st}row contains 1 integer, 2^{nd}row contains 2 integers, 3^{rd}row contains 3 integers and so on. In general, K^{th}row contains K integers.- We will use a integer counter to print consecutive natural numbers.
- 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 of right triangle pattern, inner loop will iterate K times. Each iteration of inner loop will increment the value of counter and print it on screen.

## C program to print right triangle star pattern

#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 ", count); count++; } printf("\n"); } return(0); }Output

Enter the number of rows 4 1 2 3 4 5 6 7 8 9 10

**Related Topics**