
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Program to print Kite Pattern in C++
In this tutorial, we will be discussing a program to print the given Kite pattern.
For this, we will be taking the input as N=5. Our task is to print the given Kite structure with the overall height of 2N+1 = 5. This includes 9 lines for the upper diamond structure and 2 for the lower incomplete diamond structure.
Example
#include <bits/stdc++.h> #include <stdlib.h> using namespace std; int main(){ int i, j, k, sp, space = 4; char prt = '$'; //printing the upper half of the first diamond for (i = 1; i <= 5; i++){ //printing the spaces in the front for (sp = space; sp >= 1; sp--){ cout << " "; } //printing $ character for (j = 1; j <= i; j++){ cout << prt; } for (k = 1; k <= (i - 1); k++){ if (i == 1){ continue; } cout << prt; } cout << "\n"; space--; } space = 1; //printing the lower half of the first diamond for (i = 4; i >= 1; i--){ for (sp = space; sp >= 1; sp--) { cout << " "; } for (j = 1; j <= i; j++){ cout << prt; } for (k = 1; k <= (i - 1); k++){ cout << prt; } space++; cout << "\n"; } space = 3; //printing the second incomplete diamond for (i = 2; i <= 5; i++){ if ((i % 2) != 0){ for (sp = space; sp >= 1; sp--){ cout << " "; } for (j = 1; j <= i; j++){ cout << prt; } } if ((i % 2) != 0) { cout << "\n"; space--; } } return 0; }
Output
$ $$$ $$$$$ $$$$$$$ $$$$$$$$$ $$$$$$$ $$$$$ $$$ $ $$$ $$$$$
- Related Articles
- Program to print Interesting pattern in C++
- Program to print number pattern in C
- Program to print Diamond Pattern in C
- Program to print numeric pattern in C
- Program to print pyramid pattern in C
- Swift program to print spiral pattern
- Program to print a matrix in Diagonal Pattern.
- Program to print a rectangle pattern in C++
- PHP program to print the number pattern
- Python Program to print the pattern ‘G’
- Java Program to Print Diamond Star Pattern
- Java Program to Print Square Star Pattern
- Java Program to Print 8 Star Pattern
- Java Program to Print Inverted Star Pattern
- Java Program to Print X Star Pattern

Advertisements