Program to print Kite Pattern

Given task is to draw a KITE pattern using ‘$’

Example:

Output:
       $
      $$$
     $$$$$
    $$$$$$$
   $$$$$$$$$
    $$$$$$$
     $$$$$
      $$$
       $
      $$$
     $$$$$

Below is the code to implement the above problem:

Program:

C++

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ Program to print Kite Pattern
#include <bits/stdc++.h>
#include <stdlib.h>
  
using namespace std;
int main()
{
  
    int i, j, k, sp, space = 4;
    char prt = '$';
  
    for (i = 1; i <= 5; i++)
    {
  
        // For printing the space
        for (sp = space; sp >= 1; sp--) 
        {
            cout << " ";
        }
  
        // For printing the $
        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;
  
    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;
  
    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;
}
  
// This code is contributed
// by Akanksha Rai(Abby_akku)

chevron_right


C

filter_none

edit
close

play_arrow

link
brightness_4
code

// C Program to print Kite Pattern
#include <stdio.h>
#include <stdlib.h>
  
int main()
{
  
    int i, j, k, sp, space = 4;
    char prt = '$';
  
    for (i = 1; i <= 5; i++) {
  
        // For printing the space
        for (sp = space; sp >= 1; sp--) {
            printf(" ");
        }
  
        // For printing the $
        for (j = 1; j <= i; j++) {
            printf("%c", prt);
        }
  
        for (k = 1; k <= (i - 1); k++) {
            if (i == 1) {
                continue;
            }
  
            printf("%c", prt);
        }
        printf("\n");
        space--;
    }
  
    space = 1;
  
    for (i = 4; i >= 1; i--) {
        for (sp = space; sp >= 1; sp--) {
            printf(" ");
        }
  
        for (j = 1; j <= i; j++) {
            printf("%c", prt);
        }
  
        for (k = 1; k <= (i - 1); k++) {
            printf("%c", prt);
        }
  
        space++;
        printf("\n");
    }
  
    space = 3;
  
    for (i = 2; i <= 5; i++) {
        if ((i % 2) != 0) {
            for (sp = space; sp >= 1; sp--) {
                printf(" ");
            }
  
            for (j = 1; j <= i; j++) {
                printf("%c", prt);
            }
        }
  
        if ((i % 2) != 0) {
            printf("\n");
            space--;
        }
    }
  
    return 0;
}

chevron_right


Java

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Program to print Kite Pattern
import java.io.*;
  
class GFG
{
public static void main(String[] args)
{
  
    int i, j, k, sp, space = 4;
    char prt = '$';
  
    for (i = 1; i <= 5; i++) 
    {
  
        // For printing the space
        for (sp = space; sp >= 1; sp--)
        {
            System.out.print(" ");
        }
  
        // For printing the $
        for (j = 1; j <= i; j++)
        {
            System.out.print(prt);
        }
  
        for (k = 1; k <= (i - 1); k++) 
        {
            if (i == 1
            {
                continue;
            }
  
            System.out.print(prt);
        }
        System.out.println();
        space--;
    }
  
    space = 1;
  
    for (i = 4; i >= 1; i--) 
    {
        for (sp = space; sp >= 1; sp--) 
        {
            System.out.print(" ");
        }
  
        for (j = 1; j <= i; j++) 
        {
          System.out.print(prt);
        }
  
        for (k = 1; k <= (i - 1); k++) 
        {
            System.out.print(prt);
        }
  
        space++;
        System.out.println();
    }
  
    space = 3;
  
    for (i = 2; i <= 5; i++) 
    {
        if ((i % 2) != 0
        {
            for (sp = space; sp >= 1; sp--) 
            {
                System.out.print(" ");
            }
  
            for (j = 1; j <= i; j++) 
            {
                System.out.print(prt);
            }
        }
  
        if ((i % 2) != 0)
        {
            System.out.println();
            space--;
        }
    }
}
}
  
// This code is contributed by inder_verma..

chevron_right


Python3

# Python3 Program to print Kite Pattern
if __name__ == ‘__main__’:



space = 4
prt = ‘$’

for i in range(1, 6):

# For printing the space
for sp in range(space, 0, -1):
print(end = ” “)

# For printing the $
for j in range(1, i + 1):
print(prt, end = “”)

for k in range(1, i):

if (i == 1):

continue

print(prt, end = “”)

print()
space -= 1

space = 1

for i in range(4, 0, -1):

for sp in range(space, 0, -1):
print(end = ” “)

for j in range(1, i + 1):
print(prt, end = “”)

for k in range(1, i):
print(prt, end = “”)

space += 1
print()

space = 3

for i in range(2, 6):

if ((i % 2) != 0):

for sp in range(space, 0, -1):
print(” “, end = “”)

for j in range(1, i + 1):
print(prt, end = “”)

if ((i % 2) != 0):
print()
space -= 1

# This code is contributed by
# mohit kumar 29

C#

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# Program to print Kite Pattern
using System;
  
class GFG
{
public static void Main()
{
  
    int i, j, k, sp, space = 4;
    char prt = '$';
  
    for (i = 1; i <= 5; i++) 
    {
  
        // For printing the space
        for (sp = space; sp >= 1; sp--)
        {
            Console.Write(" ");
        }
  
        // For printing the $
        for (j = 1; j <= i; j++)
        {
            Console.Write(prt);
        }
  
        for (k = 1; k <= (i - 1); k++) 
        {
            if (i == 1) 
            {
                continue;
            }
  
            Console.Write(prt);
        }
        Console.WriteLine();
        space--;
    }
  
    space = 1;
  
    for (i = 4; i >= 1; i--) 
    {
        for (sp = space; sp >= 1; sp--) 
        {
            Console.Write(" ");
        }
  
        for (j = 1; j <= i; j++) 
        {
            Console.Write(prt);
        }
  
        for (k = 1; k <= (i - 1); k++) 
        {
            Console.Write(prt);
        }
  
        space++;
        Console.WriteLine();
    }
  
    space = 3;
  
    for (i = 2; i <= 5; i++) 
    {
        if ((i % 2) != 0) 
        {
            for (sp = space; sp >= 1; sp--) 
            {
                Console.Write(" ");
            }
  
            for (j = 1; j <= i; j++) 
            {
                Console.Write(prt);
            }
        }
  
        if ((i % 2) != 0)
        {
            Console.WriteLine();
            space--;
        }
    }
}
}
  
// This code is contributed by Soumik 

chevron_right


PHP

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP Program to print Kite Pattern 
  
$space = 4; 
$prt = '$'
  
for ($i = 1; $i <= 5; $i++) 
  
    // For printing the space 
    for ($sp = $space; $sp >= 1; $sp--) 
    
        echo (" "); 
    
  
    // For printing the $ 
    for ($j = 1; $j <= $i; $j++) 
    
        echo ( $prt); 
    
  
    for ($k = 1; $k <= ($i - 1); $k++) 
    
        if ($i == 1)
        
            continue
        
  
        echo ( $prt); 
    
echo ("\n"); 
$space--; 
  
$space = 1; 
  
for ($i = 4; $i >= 1; $i--) 
    for ($sp = $space; $sp >= 1; $sp--) 
    
        echo (" "); 
    
  
    for ($j = 1; $j <= $i; $j++)
    
        echo ( $prt); 
    
  
    for ($k = 1; $k <= ($i - 1); $k++)
    
        echo ( $prt); 
    
  
    $space++; 
    echo ("\n"); 
  
$space = 3; 
  
for ($i = 2; $i <= 5; $i++) 
    if (($i % 2) != 0)
    
        for ($sp = $space; $sp >= 1; $sp--)
        
            echo (" "); 
        
  
        for ($j = 1; $j <= $i; $j++)
        
            echo ( $prt); 
        
    
  
    if (($i % 2) != 0) 
    
        echo ("\n"); 
        $space--; 
    
  
// This code is contributed
// by Sach_Code
?>

chevron_right


Output:

    $
   $$$
  $$$$$
 $$$$$$$
$$$$$$$$$
 $$$$$$$
  $$$$$
   $$$
    $
   $$$
  $$$$$


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.