Question

Print a Pattern (Right-Angled Triangle) using for loop in C Language

Updated on May 31, 2025 | By Learnzy Admin | 👁️ Views: 316 students

Solution
✔ Verified

This C program prints a right-angled triangle pattern using nested for loops.

 A right-angled triangle pattern consists of rows where each row contains an increasing number of symbols (such as asterisks *) starting from one up to the given number of rows.

 The outer for loop controls the number of rows, while the inner for loop controls the number of symbols printed in each row. This pattern programming example helps beginners understand the use of nested loops and how to control output formatting in C.

#include <stdio.h>

int main() {
    for (int i = 1; i <= 5; i++) {
        for (int j = 1; j <= i; j++) {
            printf("* ");
        }
        printf("\n");
    }
    return 0;
}

Output:--

* 
* * 
* * * 
* * * * 
* * * * * 

 

Was this solution helpful? 47
Click here to download practice questions on For Loop In C

More Questions on For Loop In C

Question 1

Print the Alphabet (A to Z) using for loop in C Language


View solution
Question 2

Calculate factorial of a Number (e.g., 5!) using for loop in C language


View solution
Question 3

Calculate sum of First 10 Natural Numbers using for loop in C Language.


View solution
Question 4

Print Table of 5 using for loop in C Language.


View solution
Question 5

Print Even Numbers from 2 to 20 using for loop in C Language.


View solution
Question 6

Print Numbers from 1 to 10 using for loop in C Language.


View solution