C Program to Print Triangle Pattern of Numbers and Stars (*)

Write a c program to print triangle pattern of numbers and stars (*). In this tutorial, we are going to write a c code to print triangle pattern of numbers , stars (*) . 

c program to print triangle pattern of numbers and stars

c program to print triangle pattern of numbers and stars

C Program to Print Triangle Pattern of 0 and 1

In this first example, We are going to write a c program which prints a triangle pattern of 0 and 1.

In this second example, we write a c program to print triangle pattern of number 1 to 5.

 

Subscribe Our Tutorials

Get Latest Updates on Facebook

C Program to 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.

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.

C Program to Print Triangle Pattern of Stars (*)

Write a program to print triangle pattern using star(*) is mostly asked an interviews when you are fresh out of college. Let’s write a c code to print triangle pattern of stars.

C Program to Print triangle pattern of Stars (*) in Reverse Order

Tagged , , , . Bookmark the permalink.