October 19, 2022 |1.5K Views

    C Program to print the G Pattern

      Share  1 Like
    Description
    Discussion

    In this video, we will write a C program to print the pattern ‘G’.

    Algorithm:
    Step 1: Take input from the user.
    Step 2: Now we have to write conditions for each of the lines that make up the pattern ‘G’.
    Step 3: Run the first loop to its height and the second loop to its width. Here we have to do iteration over lines to create the pattern G. Column-wise procedures are being carried out in this case. 
    Step 4: After satisfying the conditions this print (“*”) or space(“ “) accordingly.
    Step 5: Repeat the process until the condition is true.

    Here we analyzing the complexity of the program as well:
    Space Complexity: O(1)
    Time Complexity: O(n^2)