Print the Full Inverted Pyramid Alphabet Pattern

 EEEEEEEEE

  DDDDDDD

    CCCCC

      BBB

        A



Problem Statement:- Program to Print the Full Inverted Pyramid Alphabet Pattern.

Sample Input/Output:-


Sample Input First:5

Sample Output First: 

EEEEEEEEE
  DDDDDDD
    CCCCC
      BBB
        A

Sample Input Second: 4


Sample Output Second: 

DDDDDDD
  CCCCC
    BBB
      A

Data requirement:-


   Input Data:- row_size

  Output Data:-out

  Additional Data:-in or inn(for python), p, np

Program in C

Here is the source code of the C Program to print the Full Inverted Pyramid Alphabet Pattern.

Code:

#include <stdio.h>
int main()
{
  printf("Enter the row size:");
  int row_size;
  scanf("%d",&row_size);
  int np=row_size*2-1,in,out,p;
        for(out=row_size-1;out>=0;out--)
    {
     for(in=row_size-1;in>out;in--)
      printf(" ");
     for(p=0;p<np;p++)
           printf("%c",(out+65));
       np-=2;
       printf("\n");
       }
}

Input/Output:
Enter the row size:5
EEEEEEEEE
  DDDDDDD
    CCCCC
      BBB
        A

Program in C++

Here is the source code of the C++ Program to print the Full Inverted Pyramid Alphabet Pattern.

Code:

#include <iostream>
using namespace std;
int main()
{
  cout<<"Enter the row size:";
  int row_size;
  cin>>row_size;
  int np=row_size*2-1,in,out,p;
        for(out=row_size-1;out>=0;out--)
    {
     for(in=row_size-1;in>out;in--)
      cout<<" ";
     for(p=0;p<np;p++)
           cout<<char(out+65);
       np-=2;
       cout<<"\n";
       }
}

Input/Output:
Enter the row size:4
DDDDDDD
  CCCCC
    BBB
      A

Program in Java

Here is the source code of the Java Program to print the Full Inverted Pyramid Alphabet Pattern.

Code:

import java.util.Scanner;
public class AlphabetPattern16 {

public static void main(String[] args) {
Scanner cs=new Scanner(System.in);

    System.out.println("Enter the row size:");
    int row_size=cs.nextInt();
        int np=row_size*2-1,in,out;
        for(out=row_size-1;out>=0;out--)
    {
     for(in=row_size-1;in>out;in--)
      System.out.printf(" ");
     for(int p=0;p<np;p++)
      System.out.print((char)(out+65));
      np-=2;
     System.out.println();

    }
    cs.close();
}
}

Input/Output:
Enter the row size:
5
EEEEEEEEE
  DDDDDDD
    CCCCC
      BBB
        A

Program in Python

Here is the source code of the Python Program to print the Full Inverted Pyramid Alphabet Pattern.

Code:

row_size=int(input("Enter the row size:"))
np=row_size*2-1
for out in range(row_size-1,-1,-1):
    for inn in range(row_size,out,-1):
        print(" ",end="")
    for p in range(0,np):
        print((chr)(out+65),end="")
    np-=2
    print("\r")

Input/Output:
Enter the row size:3
 CCCCC
   BBB
     A

Post a Comment

0 Comments