Program to print the Full Pyramid Number Pattern

Write a C Program to Program to print the Full Pyramid Number Pattern.

        1
      222
    33333
  4444444
555555555

Problem statement:-  Program to print the Inverted Full Number Pattern

 Data requirement:-

   Input Data:- row_size

  Output Data:- np-out

  Additional Data:-in1, in2

Program in C
  
Here is the source code of the C Program to print the Full Pyramid Number Pattern.


#include <stdio.h>
int main()
{

  printf("Enter the row size:");
  int row_size,out,in1,in2;
  int np=1;
  scanf("%d",&row_size);
  for(out=0;out<row_size;out++)
       {
       for(in1=row_size-1;in1>out;in1--)
       {
            printf(" ");
       }
       for(in2=0;in2<np;in2++)
       {
           printf("%d",np-out);
       }
       np+=2;
       printf("\n");
       }
}


Input/Output:
Enter the row size:5
       1
      222
    33333
  4444444
555555555

Write a C++ Program to print the Full Pyramid Number Pattern.

Program in C++
  
Here is the source code of the C++ Program to print the Full Pyramid Number Pattern.

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


Input/Output:
Enter the row size:4
      1
    222
  33333
4444444

Write a Java Program to print the Full Pyramid Number Pattern.

Program in Java
  
Here is the source code of the Java Program to print the Full Pyramid Number Pattern.


import java.util.Scanner;
public class P31 {

public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
        System.out.println("Enter the row size:");

        int row_size,out,in1,in2;
        int np=1;
        row_size=cs.nextInt();
 
       for(out=0;out<row_size;out++)
       {
       for(in1=row_size-1;in1>out;in1--)
       {
           System.out.print(" ");
       }
       for(in2=0;in2<np;in2++)
       {
           System.out.print(np-out);
       }
       np+=2;
       System.out.println();
       }
     cs.close();
}
}


Input/Output:
Enter the row size:
6
          1
        222
      33333
    4444444
  555555555
66666666666

Write a Python Program to print the Full Pyramid Number Pattern.

Program in Python
  
Here is the source code of the Python Program to print the Full Pyramid Number Pattern.


row_size=int(input("Enter the row size:"))
np=1
for out in range(0,row_size):
    for in1 in range(row_size-1,out,-1):
        print(" ",end="")
    for in2 in range(0, np):
        print(np-out,end="")
    np+=2
    print("\r")


Input/Output:
Enter the row size:4
      1
    222
  33333
4444444

Post a Comment

0 Comments