# PATTERN PRINTING – 30

This pattern combination of 2 basic right angled triangle.

It would be much easier for you to understand this pattern if you know basic right angled triangle well.

I suggest you to watch this video first : http://wethecomputerguys.com/2014/02/27/c-practical-and-assignment-programs-pattern-printing-1/

So by now we know how to print a right angled triangle.

To print the above pattern we divide the figure in 3 parts as shown in the figure below:

The 3 parts are:

– The red triangle containing stars.

– The central blue region.

– The yellow triangle containing stars.

**Logic for the code:**

– Firstly we take input of number of rows(n)

– For each row(i : i goes from 0 to n-1)

– Print stars(number equal to row number).

– Print spaces(n-i-1).

– Print stars(number equal to row number).

– Newline.

#include<stdio.h>; int main(){ int n,i,j; printf("Enter number of rowsn"); scanf("%d",&n); // For each row for(i=0;i<n;i++){ // PRint stars for(j=0;j<=i;j++) printf("*"); // Print spaces for(j=0;j<n-i-1;j++) printf(" "); // Print stars for(j=0;j<=i;j++) printf("*"); // New Line printf("n"); } return 0; }

Next Post: Pattern Printing 31

Category: Printing Pattern

Previous Post: Pattern Printing 29

## 2 Responses

[…] Previous PostIn an array of integers verify whether a given element is a row-peak. An element is said to be row-peak if it is a row-wise local maxima i.e it is strictly greater than its adjacent row neighbours.Next PostPATTERN PRINTING – 30 […]

[…] Previous Pattern […]