A
BBB
CCCCC
DDDDDDD
EEEEEEEEE
Problem Statement:- Program to print the Full Pyramid Alphabet Pattern.
Sample Input/Output:-
Data requirement:-
Input Data:- row_size
Output Data:-out
Additional Data:-in or inn(for python), np, p
Here is the source code of the C Program to print the Full Pyramid Alphabet Pattern.
Input/Output:
Input/Output:
Input/Output:
Input/Output:
Output Data:-out
Additional Data:-in or inn(for python), np, p
Program in C
Here is the source code of the C Program to print the Full Pyramid Alphabet Pattern.
Code:
#include <stdio.h>
int main()
{
printf("Enter the row size:");
int row_size,out,in,p;
int np=1;
scanf("%d",&row_size);
for(out=0;out<row_size;out++)
{
for(in=row_size-1;in>out;in--)
{
printf(" ");
}
for(p=0;p<np;p++)
{
printf("%c",(out+65));
}
np+=2;
printf("\n");
}
}
Enter the row size:5
A
BBB
CCCCC
DDDDDDD
EEEEEEEEE
Program in C++
Here is the source code of the C++ Program to print the Full Pyramid Alphabet Pattern.
Code:
#include <iostream>
using namespace std;
int main()
{
cout<<"Enter the row size:";
int row_size,out,in,p;
int np=1;
cin>>row_size;
for(out=0;out<row_size;out++)
{
for(in=row_size-1;in>out;in--)
{
cout<<" ";
}
for(p=0;p<np;p++)
{
cout<<(char)(out+65);
}
np+=2;
cout<<"\n";
}
}
Enter the row size:4
A
BBB
CCCCC
DDDDDDD
Program in Java
Here is the source code of the Java Program to print the Full Pyramid Alphabet Pattern.
Code:
import java.util.Scanner;
public class AlphabetPattern15 {
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=1,in,out;
for(out=0;out<row_size;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();
}
}
Enter the row size:
5
A
BBB
CCCCC
DDDDDDD
EEEEEEEEE
Program in Python
Here is the source code of the Python Program to print the Full Pyramid Alphabet Pattern.
Code:
row_size=int(input("Enter the row size:"))
np=1
for out in range(0,row_size):
for inn in range(row_size-1,out,-1):
print(" ",end="")
for p in range(0, np):
print(chr(out+65),end="")
np+=2
print("\r")
Enter the row size:3
A
BBB
CCCCC
1 Comments
A
ReplyDelete**
BBB
****
CCCCC
Please do not Enter any spam link in the comment box