New: 203 pattern programs with tested code in C, C++, Java and Python Explore patterns

Kite Star Pattern

Read summary with AI tools

The kite star pattern is a diamond with a short tail hanging from its bottom point. It reuses the diamond star pattern and adds two more rows from the top of a pyramid.

Quick answer: Print the diamond first: a pyramid for rows 1 to n, then rows n − 1 down to 1. Then print rows 2 and 3 of the same pyramid again; they hang under the point and form the tail. Every row uses the same rule, n − i spaces and 2i − 1 stars.

This program is part of the Tricky Patterns collection.

Table of contents8 sections
  1. Output
  2. How the kite star pattern works
  3. Program in C
  4. Program in C++
  5. Program in Java
  6. Program in Python
  7. Time and space complexity
  8. Frequently asked questions

Kite Star Pattern output

Output (n = 4):

   *
  ***
 *****
*******
 *****
  ***
   *
  ***
 *****
Kite Star Pattern layout diagram, row by row (n = 4)
How each row of the kite star pattern is built (n = 4). Blue cells are printed characters; grey dots are spaces.

How the kite star pattern works

All three parts of the kite print rows from the same pyramid; they only choose different rows. The upper half counts up to the widest row, the lower half counts back down to a single star, and the tail picks rows 2 and 3 so that it widens slightly under the point. Because each row is built with the same spaces and stars, everything lines up on the centre column automatically.

  1. Run the outer loop for i from 1 to n, one row per pass (upper half of the kite).
  2. Print n − i spaces.
  3. Print 2 × i − 1 stars.
  4. Move to the next line.
  5. Run the outer loop for i from n − 1 down to 1, one row per pass (lower half).
  6. Print n − i spaces.
  7. Print 2 × i − 1 stars.
  8. Move to the next line.
  9. Run the outer loop for i from 2 to 3, one row per pass (the tail).
  10. Print n − i spaces.
  11. Print 2 × i − 1 stars.
  12. Move to the next line.

Key takeaways

  • The kite is a diamond plus a short pyramid tail.
  • All three parts print rows of the same pyramid, so they share one centre line.
  • Choosing which rows to print, not new formulas, is what changes the shape.
  • Start the tail at row 2 so it does not repeat the single star of the point.

Kite Star Pattern in C

#include <stdio.h>

int main(void) {
    int n = 4;

    // upper half of the kite
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n - i; j++)
            printf(" ");
        for (int j = 1; j <= 2 * i - 1; j++)
            printf("*");
        printf("\n");
    }

    // lower half
    for (int i = n - 1; i >= 1; i--) {
        for (int j = 1; j <= n - i; j++)
            printf(" ");
        for (int j = 1; j <= 2 * i - 1; j++)
            printf("*");
        printf("\n");
    }

    // the tail
    for (int i = 2; i <= 3; i++) {
        for (int j = 1; j <= n - i; j++)
            printf(" ");
        for (int j = 1; j <= 2 * i - 1; j++)
            printf("*");
        printf("\n");
    }
    return 0;
}

Kite Star Pattern in C++

#include <iostream>
using namespace std;

int main() {
    int n = 4;

    // upper half of the kite
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n - i; j++)
            cout << " ";
        for (int j = 1; j <= 2 * i - 1; j++)
            cout << "*";
        cout << endl;
    }

    // lower half
    for (int i = n - 1; i >= 1; i--) {
        for (int j = 1; j <= n - i; j++)
            cout << " ";
        for (int j = 1; j <= 2 * i - 1; j++)
            cout << "*";
        cout << endl;
    }

    // the tail
    for (int i = 2; i <= 3; i++) {
        for (int j = 1; j <= n - i; j++)
            cout << " ";
        for (int j = 1; j <= 2 * i - 1; j++)
            cout << "*";
        cout << endl;
    }
    return 0;
}

Kite Star Pattern in Java

public class KiteStar {
    public static void main(String[] args) {
        int n = 4;

        // upper half of the kite
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n - i; j++)
                System.out.print(" ");
            for (int j = 1; j <= 2 * i - 1; j++)
                System.out.print("*");
            System.out.println();
        }

        // lower half
        for (int i = n - 1; i >= 1; i--) {
            for (int j = 1; j <= n - i; j++)
                System.out.print(" ");
            for (int j = 1; j <= 2 * i - 1; j++)
                System.out.print("*");
            System.out.println();
        }

        // the tail
        for (int i = 2; i <= 3; i++) {
            for (int j = 1; j <= n - i; j++)
                System.out.print(" ");
            for (int j = 1; j <= 2 * i - 1; j++)
                System.out.print("*");
            System.out.println();
        }
    }
}

Kite Star Pattern in Python

n = 4

# upper half of the kite
for i in range(1, n + 1):
    for j in range(1, n - i + 1):
        print(" ", end="")
    for j in range(1, 2 * i):
        print("*", end="")
    print()

# lower half
for i in range(n - 1, 0, -1):
    for j in range(1, n - i + 1):
        print(" ", end="")
    for j in range(1, 2 * i):
        print("*", end="")
    print()

# the tail
for i in range(2, 4):
    for j in range(1, n - i + 1):
        print(" ", end="")
    for j in range(1, 2 * i):
        print("*", end="")
    print()

Time and space complexity

The program prints one character for each position in the pattern, so for n rows it runs in O(n²) time. It only needs a few loop variables, so the extra memory is O(1).

Frequently asked questions

How do I make the tail longer?

Print more rows in the third part, for example rows 2 to 4. For a narrow tail print a single star on each row instead, with n − 1 spaces in front.

Can I print a hollow kite?

Yes. Print a star only at the first and last position of each row, as in the hollow diamond star pattern, and keep the tail solid or hollow.

How do I let the user choose the size?

Read n from the keyboard instead of fixing it in the code: scanf("%d", &n); in C, cin >> n; in C++, new Scanner(System.in).nextInt() in Java and int(input()) in Python.

Authored by

Ghanendra Yadav runs Pattern Programs from Bangalore, India. The site started in 2020 to help students practise loops and logic through pattern programs in C, C++, Java and Python. Every program published here is compiled and run before it goes live, and the output shown is the real output.

Latest articles

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.