- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to print Inverse Diamond pattern on C++
In this tutorial, we will be discussing a program to print given inverse diamond pattern.
For this, we will be provided with the value of N. Our task is to print an inverse the diamond pattern according to the height of 2N-1.
Example
#include<bits/stdc++.h> using namespace std; //printing the inverse diamond pattern void printDiamond(int n){ cout<<endl; int i, j = 0; //loop for the upper half for (i = 0; i < n; i++) { //left triangle for (j = i; j < n; j++) cout<<"*"; //middle triangle for (j = 0; j < 2 * i + 1; j++) cout<<" "; //right triangle for (j = i; j < n; j++) cout<<"*"; cout<<endl; } //loop for the lower half for (i = 0; i < n - 1; i++) { //left triangle for (j = 0; j < i + 2; j++) cout<<"*"; //middle triangle for (j = 0; j < 2 * (n - 1 - i) - 1; j++) cout<<" "; //right triangle for (j = 0; j < i + 2; j++) cout<<"*"; cout<<endl; } cout<<endl; } int main(){ int n = 5; printDiamond(n); return 0; }
Output
***** ***** **** **** *** *** ** ** * * ** ** *** *** **** **** ***** *****
- Related Articles
- Program to print Diamond Pattern in C
- C Program to print hollow pyramid and diamond pattern
- Java Program to Print Diamond Star Pattern
- Swift program to Print Diamond Star Pattern
- Golang Program To Print Diamond Star Pattern
- Program to print hollow pyramid and diamond pattern in C++
- Java Program to Print Half Diamond Star Pattern
- Swift Program to Print Half Diamond Star Pattern
- Swift program to Print Half Diamond Numeric Pattern
- Golang Program to Print Half Diamond Star Pattern
- Swift Program to Print half Diamond Binary Pattern
- Program to print an inverse pyramid character pattern in C++
- How to print the stars in Diamond pattern using C language?
- C++ Program to print the diamond shape
- C Program for diamond pattern with different layers

Advertisements