2 2
  3 3 3
 4 4 4 4
5 5 5 5 5
Problem Statement:- Program to print the Full Pyramid Number Pattern.
Sample Input/Output:-
Data requirement:-
Input Data:- row_size
Output Data:- out
Additional Data:-in or inn(for python), p
Program in C
Here is the source code of the C Program to print the Full Pyramid Number Pattern.
Code:
#include<stdio.h>
int main()
{
    int out,in,p;
    printf("Enter the row size:");
	    int row_size;
	    scanf("%d",&row_size);
	    for(out=1;out<=row_size;out++)
	    {
	     for(in=row_size-1;in>=out;in--)
	     {
	    	 printf(" ");
	     }
	    	 for(p=1;p<=out;p++)
	    	 {
	    		 printf("%d ",out);
	    	 }
	    	 printf("\n");
}}
Enter the row size:5
    1
   2 2
  3 3 3
 4 4 4 4
5 5 5 5 5
Program in C++
Here is the source code of the C++ Program to print the Full Pyramid Number Pattern.
Code:
#include<iostream>
using namespace std;
int main()
{
    int out,in,p;
    cout<<"Enter the row size:";
	    int row_size;
	    cin>>row_size;
	    for(out=1;out<=row_size;out++)
	    {
	     for(in=row_size-1;in>=out;in--)
	     {
	    	 cout<<" ";
	     }
	    	 for(p=1;p<=out;p++)
	    	 {
	    		 cout<<out<<" ";
	    	 }
	    	 cout<<"\n";
}}
Enter the row size:4
   1
  2 2
 3 3 3
4 4 4 4
Program in Java
Here is the source code of the Java Program to print the Full Pyramid Number Pattern.
Code:
import java.util.Scanner;
public class NumberPattern12 {
	public static void main(String[] args) {
		Scanner cs=new Scanner(System.in);
        int out,in,p;
	    System.out.println("Enter the row size:");
	    int row_size=cs.nextInt();
	    for(out=1;out<=row_size;out++)
	    {
	     for(in=row_size-1;in>=out;in--)
	     {
	    	 System.out.printf(" ");
	     }
	    	 for(p=1;p<=out;p++)
	    	 {
	    		 System.out.print(out+" ");
	    	 }
	    	 System.out.println();
	    }
	    cs.close();
	}
}
Enter the row size:
6
     1 
    2 2 
   3 3 3 
  4 4 4 4 
 5 5 5 5 5 
6 6 6 6 6 6 
Program in Python
Here is the source code of the Python Program to print the Full Pyramid Number Pattern.
Code:
row_size=int(input("Enter the row size:"))
for out in range(1,row_size+1):
    for inn in range(row_size,out,-1):
        print(" ",end="")
    for p in range(1,out+1):
        print(out,end=" ")
    print("\r")
Enter the row size:4
   1 
  2 2 
 3 3 3 
4 4 4 4 
 

0 Comments
Please do not Enter any spam link in the comment box