Program to print the Full Pyramid Number Pattern

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

        1
      321
    54321
  7654321
987654321

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

 Data requirement:-

   Input Data:- row_size

  Output Data:- in2

  Additional Data:-in1, out, np

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=1;out<=row_size;out++)
       {
       for(in1=row_size-1;in1>=out;in1--)
       {
            printf(" ");
       }
       for(in2=np;in2>=1;in2--)
       {
           printf("%d",in2);
       }
       np+=2;
       printf("\n");
       }
}

Input/Output:

Enter the row size:5
        1
      321
    54321
  7654321
987654321

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=1;out<=row_size;out++)
       {
       for(in1=row_size-1;in1>=out;in1--)
       {
            cout<<" ";
       }
       for(in2=np;in2>=1;in2--)
       {
           cout<<in2;
       }
       np+=2;
       cout<<"\n";
       }
}

Input/Output:

Enter the row size:4
        1
      321
    54321
  7654321

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 P34 {

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=1;out<=row_size;out++)
       {
       for(in1=row_size-1;in1>=out;in1--)
       {
           System.out.print(" ");
       }
       for(in2=np;in2>=1;in2--)
       {
           System.out.print(in2);
       }
       np+=2;
       System.out.println();
       }
     cs.close();
}
}

Input/Output:

Enter the row size:
3
        1
      321
    54321

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(np,0,-1):
        print(in2,end="")
    np+=2
    print("\r")

Input/Output:

Enter the row size:4
        1
      321
    54321
  7654321

Post a Comment

0 Comments