Jul 02, 2015 Step by step descriptive logic to print reverse pyramid star pattern. Input number of rows to print from user. Store it in a variable say rows. To iterate through rows, run an outer loop from 1 to rows. The loop structure should look like for(i=1; iprint spaces, run an inner loop from 1.
This Program first takes the numbers of rows in pattern and then prints the corresponding pattern using nested for loops. This kind of problems are useful for beginners to understands the fundamentals of loops and spaces. Here, we will discuss about four variations of patterns using '*' character, right triangle, inverted right triangle, pyramid and inverted pyramid.
In this program, we first take the number of rows in the pattern as input from user using scanf function. Then we use two for loops to print triangle pattern. Outer for loop prints one horizontal row of pattern in one iteration whereas inner for loop prints n stars for nth row in one iteration.
Program OutputThis c program is similar to above program, the only difference is the pattern is inverted. For ith row we are printing (rows - i + 1) starts.
In this program, we are printing a pyramid pattern in which ith row contains (2*i - 1) space separated stars. We first take the number of rows in the pattern as input from user using scanf function. One iteration of outer for loop will print a row of pyramid. Inner for loop prints the initial spaces for every line and nested while loop prints (2*r - 1) space separated stars for rth row of pyramid.
Program OutputC program to print diamond star pattern |
C Program to print rhombus star pattern |
C program to print heart shape star pattern |
C program to print hut shape star pattern |
C program to print binary triangle pattern |
C program to print hollow pyramid star pattern |
C program to print hollow square star pattern |
C program to print pascal triangle till N rows |
C programs to print star triangle patterns |
C Program to print a matrix diagonally |
C program to print lower triangular matrix |
List of all C programs |