E D C B A
E D C B
E D C
E D
E
Problem Statement:- Program to Print the Alphabet Inverted Half Pyramid Pattern.
Sample Input/Output:-
Data requirement:-
Input Data:- row_size
Output Data:-in
Additional Data:- out
Program in C
Here is the source code of the C Program to Print the Alphabet Inverted Half Pyramid Pattern.
Code:
#include <stdio.h>int main(){ printf("Enter the row size(In Alphabet):"); int out, in; char row_size; scanf("%c", &row_size); for (out = 'A'; out <= row_size; out++) { for (in = row_size; in >= out; in--) printf("%c ", in); printf("\n"); }}
Input/Output:
Enter the row size(In Alphabet):E
E D C B A
E D C B
E D C
E D
E
#include <stdio.h>int main(){ printf("Enter the row size(In Alphabet):"); int out, in; char row_size; scanf("%c", &row_size); for (out = 'A'; out <= row_size; out++) { for (in = row_size; in >= out; in--) printf("%c ", in); printf("\n"); }}
Program in C++
Here is the source code of the C++ Program to Print the Alphabet Inverted Half Pyramid Pattern.
Code:
#include <iostream>using namespace std;int main(){ cout << "Enter the row and column size(In Alphabet):"; int out, in; char row_size; cin >> row_size; for (out = 'A'; out <= row_size; out++) { for (in = row_size; in >= out; in--) cout << char(in) << " "; cout << "\n"; }}
#include <iostream>using namespace std;int main(){ cout << "Enter the row and column size(In Alphabet):"; int out, in; char row_size; cin >> row_size; for (out = 'A'; out <= row_size; out++) { for (in = row_size; in >= out; in--) cout << char(in) << " "; cout << "\n"; }}
Input/Output:
Enter the row size(In Alphabet):D
D C B A
D C B
D C
D
Program in Java
Here is the source code of the Java Program to Print the Alphabet Inverted Half Pyramid Pattern.
Code:
import java.util.Scanner;
public class AlphabetInvertedHalfPyramidPattern {
public static void main(String[] args) { Scanner cs = new Scanner(System.in); System.out.println("Enter the row and column size(In Alphabet):"); char out, in; char row_size = cs.next().charAt(0); for (out = 'A'; out <= row_size; out++) { for (in = row_size; in >= out; in--) System.out.print(in + " "); System.out.println(); } cs.close(); }}
Input/Output:
Enter the row size(In Alphabet):F
F E D C B A
F E D C B
F E D C
F E D
F E
F
import java.util.Scanner;
public class AlphabetInvertedHalfPyramidPattern {
public static void main(String[] args) { Scanner cs = new Scanner(System.in); System.out.println("Enter the row and column size(In Alphabet):"); char out, in; char row_size = cs.next().charAt(0); for (out = 'A'; out <= row_size; out++) { for (in = row_size; in >= out; in--) System.out.print(in + " "); System.out.println(); } cs.close(); }}
Program in Python
Here is the source code of the Python Program to Print the Alphabet Inverted Half Pyramid Pattern.
Code:
row_size = input("Enter the row and column size(In Alphabet):")for out in range(ord('A'), ord(row_size)+1): for i in range(ord(row_size), out-1, -1): print(chr(i), end=" ") print("\r")
Input/Output:
Enter the row size(In Alphabet):D
D C B A
D C B
D C
D
row_size = input("Enter the row and column size(In Alphabet):")for out in range(ord('A'), ord(row_size)+1): for i in range(ord(row_size), out-1, -1): print(chr(i), end=" ") print("\r")
0 Comments
Please do not Enter any spam link in the comment box