Introduction
The different programming languages are spaced full Pyramid pattern of numbers will be discussed in this article. Pyramid designs are all made out of polygons. The interviewer frequently asks these questions to test the programmer's logical and reasoning abilities. We can develop multiple pyramid patterns in C, C++, JAVA, PYTHON, PHP, and other computer languages once we grasp the logic of the code.

Now we'll use loops and if expressions to generate numerous pyramid patterns in different programming languages.
Problem Statement
Write a program that prints the spaced full pyramid number pattern.
For this program, we have sample inputs as given below:
Sample Input 1 | Sample Output 1 |
---|---|
7 |
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 |
Sample Input 2 | Sample Output 2 |
3 |
1 2 2 3 3 3 |
For this program, this data is required:
For input | myInput |
For output | myOutput |
Addition Information (While using Python) | We need x and y. |
Program in C
The source code for the C program that prints the spaced full pyramid number pattern is mentioned below:
#include < stdio.h >
int main()
{
int myOutput,x, y;
printf("Enter the size of the row:");
int myInput;
scanf("%d",& myInput);
for (myOutput = 1; myOutput <= myInput; myOutput++) {
for (x= myInput - 1;x>= myOutput;x --)
{
printf(" ");
}
for (y = 1; y <= myOutput; y++) {
printf("%d ", myOutput);
}
printf("\n");
}
}
Output
Related Problems
Print Spaced Full Pyramid Star Pattern
#include <stdio.h>
int main() {
int i, space, rows, k = 0;
printf("Enter the size of the rows: ");
scanf("%d", &rows);
for (i = 1; i <= rows; ++i, k = 0) {
for (space = 1; space <= rows - i; ++space) {
printf(" ");
}
while (k != 2 * i - 1) {
printf("* ");
++k;
}
printf("\n");
}
return 0;
}
Output
Print pyramid of stars in reverse direction
#include<stdio.h>
int main()
{
int i, j, rows;
printf("Enter the size of rows: ");
scanf("%d", &rows);
for(i=1; i<=rows; i++)
{
for(j=1; j<i; j++)
{
printf(" ");
}
for(j=1; j<=(rows*2 -(2*i-1)); j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Output
Program in C++
The source code for the C++ program that prints the spaced full pyramid number pattern is mentioned below:
#include<iostream>
using namespace std;
int main()
{
int myOutput,x,y;
cout<<"Enter the size of the row: "<<endl;
int myInput;
cin>>myInput;
for(myOutput=1;myOutput<=myInput;myOutput++)
{
for(x=myInput-1;x>=myOutput;x--)
{
cout<<" ";
}
for(y=1;y<=myOutput;y++)
{
cout<<myOutput<<" ";
}
cout<<"\n";
}
}
Output
Another Method
#include <iostream>
using namespace std;
int main()
{
int rows, count = 0, count1 = 0, k = 0;
cout << "Enter the size of rows: ";
cin >> rows;
for(int i = 1; i <= rows; ++i)
{ for(int space = 1; space <= rows-i; ++space)
{
cout << " ";
++count;
}
while(k != 2*i-1)
{ if (count <= rows-1)
{
cout << i+k << " ";
++count;
}
else
{
++count1;
cout << i+k-2*count1 << " ";
}
++k;
}
count1 = count = k = 0;
cout << endl;
}
return 0;
}
Output
Program in Java
The source code for the Java program that prints the spaced full pyramid number pattern is mentioned below:
import java.util.Scanner;
public class myPyramidNumberPattern {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int myOutput,x,y;
System.out.println("Enter the size of the row: ");
int myInput=s.nextInt();
for(myOutput=1;myOutput<=myInput;myOutput++)
{
for(x=myInput-1;x>=myOutput;x--)
{
System.out.printf(" ");
}
for(y=1;y<=myOutput;y++)
{
System.out.print(myOutput+" ");
}
System.out.println();
}
s.close();
}
}
Output
Program in Python
The source code for the Python program that prints the spaced full pyramid number pattern is mentioned below:
myInput=int(input("Enter the size of the row:\n"))
for myOutput in range(1,myInput+1):
for x in range(myInput,myOutput,-1):
print(" ",end="")
for y in range(1,myOutput+1):
print(myOutput,end=" ")
print("\r")
Output
Related Examples
Print the pattern which is given below:
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
rows = int(input("Enter the size of the rows: "))
k = 0
count=0
count1=0
for i in range(1, rows+1):
for space in range(1, (rows-i)+1):
print(" ", end="")
count+=1
while k!=((2*i)-1):
if count<=rows-1:
print(i+k, end=" ")
count+=1
else:
count1+=1
print(i+k-(2*count1), end=" ")
k += 1
count1 = count = k = 0
print()
Output