C Program to Print Binary Numbers Pyramid Pattern

Problem Statement : Generate Following Pattern of Pyramid

Program Explanation :

We have declared some of the variables. We have declared count variable,

First and Third Line is Starting with 1 , while 2nd and 4th Line is starting with 0, So for first and third line count will be 1 and for even line number count will be equal to 0.

Line NumberValue of Count

Outer for loop will decide the line. In this pyramid we need to print 5 lines so we have for loop which can execute 5 times.

As each iteration of for loop is new line we need to print newline character on each line
below table explains how many times inner loop is executed –

Value of iNo of times inner Loop gets executedValues of j
221 2
331 2 3
441 2 3 4

below lines will decide the value of count for next iteration –