Open In App

Program to print V and inverted-V pattern

Last Updated : 17 Feb, 2023
Comments
Improve
Suggest changes
1 Like
Like
Report

Inverted V pattern: Given the value of n, print the inverted V pattern.
Examples : 
 

Input : n = 5
Output : 

    E
   D D
  C   C
 B     B
A       A

Input : n = 7
Output : 

      G
     F F
    E   E
   D     D
  C       C
 B         B
A           A


 


Below is the program to print the above pattern 
 

C++
Java Python3 C# PHP JavaScript

Output:  

    E
   D D
  C   C
 B     B
A       A

Time Complexity: O(n2), where n represents the given input.
Auxiliary Space: O(1), no extra space is required, so it is a constant.
V pattern: Given the value of n, print the V pattern.
Examples : 
 

Input : n = 5
Output : 

E       E
 D     D
  C   C
   B B
    A

Input : n = 7
Output : 

G           G
 F         F
  E       E
   D     D
    C   C
     B B
      A


 


Below is the program to print the above pattern 
 

C++
Java Python3 C# PHP JavaScript

Output: 

E       E
 D     D
  C   C
   B B
    A

Time Complexity: O(n2), where n represents the given input.
Auxiliary Space: O(1), no extra space is required, so it is a constant.


Similar Reads