Pattern Programs in C – Part 3

Pattern Programs in C Made Easy – Part 3


Developing Pattern Programs in C along with the For Loop is one of the most daunting and intimidating topics in C Programming.

This article will definitely help you out How to Build Pattern Programs in C Programming Language and get a good hold over such kind of programs.

We have tried to get you the best Pattern Programming Methods in C Programming Language with a deep analysis and a descriptive explanation on Pattern Programs in C. We will focus on developing the Algorithm and Logic Building Approach with the following program.

Let us First start with some basics and eventually we shall move on some complicated topics.

Before we indulge ourselves into Pattern Programming, it is very important to know How Does a For Loop Work. Every Pattern Program needs a Looping Control System. Usually, we use For Loop because of its easy to use approach.

A For Loop executes a series of commands(statements) repeatedly. It executes a set of statements till a particular condition evaluates to be True.

Before going ahead with this Program, I would suggest you to check out Pattern Programming – Part 2 to clear your Fundamentals about Pattern Programming.


Let us Look at a C Program to print the following Pattern:
5      4      3      2      1
4      3      2      1
3      2      1
2      1


Source Code:



Pattern Programs in C



Here, we have a Pattern program that prints Numbers that Decrement Row-Wise as well as Column-Wise eventually.

Note: The Outer For Loop works to print Rows and the Inner For Loop works to print Columns.

In the First For Loop initially, i=5. Hence, 5 gets printed as the first element. Then, the control goes inside the second For Loop. There, j=i-1 i.e., It is one less than the Current Value of i. Hence, 4 gets printed. the Inner Loop executes until i>=1 does not become False.

After the Inner For Loop executes, the Program Control comes to the Outer For Loop. It now increments the value of i by 1. Hence, i=2. It, therefore gets printed on the second line (first element). Similarly, the Control goes into he Inner For Loop. It Executes till 1.

This sequence goes on until the Outer For Loop’s Condition does not becomes False.

Note: We have used printf(“n”) after the inner loop as it takes the program cursor to the next line after printing the First row.

Developing Pattern Programs in C Programming is very easy if you understand the Looping Concepts clearly. Initially, it may look intimidating. But, eventually it will get easier.


Let's Discuss