Program to print triangle pattern of numbers and stars (*)

Write a program to print triangle pattern of numbers and stars (*). In this program i’ll show how to create triangle pattern of numbers , stars (*) . These type of questions are very important in terms of interviews as well.

Program to Print Triangle of numbers

 

Print triangle of numbers in Reverse order

To print the triangle pattern in reverse order. Initialize i with input number. So in my case it’s 5. Then after printing every row start decrementing it.

Subscribe Our Tutorials

Get Latest Updates on Facebook

1. In first for loop, initialize i with 5. Check the condition i is greater than or equal to 1. And after every iteration we start decrementing it’s value.

2. In second loop, j is initialized with the value of i.

So let’s the value initialized is 5. 5 is greater than or equal to 1. So it prints

5 4 3 2 1

Now the condition goes false after 1 so it’s terminate. Similarly it goes for next iteration.

Print triangle pattern of Stars (*)

print triangle pattern using * is generally most asked question in exams and interviews. The code is very simple. Let’s check it’s c code.

Print triangle pattern of Stars (*) in Reverse Order

Tagged , , , . Bookmark the permalink.