July 26, 2022 |11.6K Views

    C++ Program to Print Swastika Pattern

    Description
    Discussion

    In this video, we will see a C++ Program to Print Swastika Pattern.

    Conditions for Printing Swastika:
    1. (j==1 && i<=n/2+1)
    2. (i==1 && j>=n/2+1)
    3. (j==n && i>=n/2+1)
    4. (i==n/2+1)
    5. (j==n/2+1)

    The number of rows and columns should be the same and an odd number. This will generate a perfect swastika pattern.

    Let's take an example:
    Input : row = 7, column = 7
    Output:
    *      * * * *
    *      *
    *      *
    * * * * * * *
            *       *
            *       *
    * * * *       *

    Here we use conditional operators for making a code optimum. Apart from that, we will see the time and space complexity of this program.

    Time complexity: N^2
    Space complexity: Constant (1)

    Program to Print Swastika Pattern: 
    https://www.geeksforgeeks.org/swastika-patternprogram-to-print-swastika-pattern/