C program to generate Double pyramid number pattern
- Home
- Diamond pattern
- C program to generate Double pyramid number pattern
- On
- By
- 0 Comment
- Categories: Diamond pattern, Number pattern
C program to generate Double pyramid number pattern
C program to generate Double pyramid number pattern
In this tutorial, we will discuss a simple concept of the C program to generate Double pyramid number pattern
In this post, we will learn how to create double(Integrated) pyramid number pattern.
We can use for loop, while loop or do while loop to display different integrated pyramid number patterns.
Here we will use for loop to print different integrated pyramid number patterns
Program 1
Generate Integrated pyramid number pattern 1
#include <stdio.h> #include <stdlib.h> int main() { int rows,i,j; printf("Enter the number of rows: "); scanf("%d",&rows); for(i=1; i<=rows; i++){ //print upper part for(j=i; j<=rows; j++){ printf("%d",j);//print number to upper part } printf("\n");//move to next line } for(i=rows-1; i>=1; i--){ //print lower part for(j=i; j<=rows; j++){ printf("%d",j);//print number } printf("\n");//move to next line } getch(); return 0; }
When the above code is executed, it produces the following result
Enter the number of rows: 6 123456 23456 3456 456 56 6 56 456 3456 23456 123456
Program 2
Generate Integrated pyramid number pattern 2
#include <stdio.h> #include <stdlib.h> int main() { int rows,i,j; printf("Enter the number of rows: "); scanf("%d",&rows); for(i=rows; i>=0; i--){ //print upper part for(j=1; j<=i; j++){ printf("%d",j);//print number printf(" "); } printf("\n");//move to next line } for(i=1; i<=rows; i++){ //print lower part for(j=1; j<=i; j++){ printf("%d",j);//print number to lower part printf(" "); } printf("\n");//move to next line } return 0; }
When the above code is executed, it produces the following result
Enter the number of rows 6 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6
Program 3
Generate Integrated pyramid number pattern 3
#include <stdio.h> #include <stdlib.h> int main() { int rows,i,j,k; printf("Enter the number of rows\n"); scanf("%d",&rows); for(i=1; i<=rows; i++){ //print upper part for(j=1; j<=i; j++){ printf(" ");//print space } for(k=i; k<=rows; k++){ printf(k);//print number printf(" "); } printf("\n"); } for(i=rows-1; i>=1; i--){ //print lower part for(j=1; j<=i; j++){ printf(" "); } for(k=i; k<=rows; k++){ printf(k);//print number printf(" "); } printf("\n"); } getch(); return 0; }
When the above code is executed, it produces the following result
Enter the number of rows: 6 1 2 3 4 5 6 2 3 4 5 6 3 4 5 6 4 5 6 5 6 6 5 6 4 5 6 3 4 5 6 2 3 4 5 6 1 2 3 4 5 6
Program 4
Generate Integrated pyramid number pattern 4
#include <stdio.h> #include <stdlib.h> int main() { int rows,i,j; printf("Enter the number of rows: "); scanf("%d",&rows); for(i=1; i<=rows; i++){ //print upper part for(j=1; j<i; j++){ printf(" ");//print space } for(j=i; j<=rows; j++){ printf("%d",j);//print number to upper part } printf("\n"); } for(i=rows-1; i>=1; i--){ for(j=1; j<i; j++){ printf(" ");//print space } for(j=i; j<=rows; j++){ //print lower part printf("%d",j);//print number to lower part } printf("\n"); } return 0; }
When the above code is executed, it produces the following result
Enter the number of roes: 6 123456 23456 3456 456 56 6 56 456 3456 23456 123456
Program 5
Generate Integrated pyramid number pattern 5
#include <stdio.h> #include <stdlib.h> int main() { int rows,i,j,k; printf("Enter the number of rows: "); scanf("%d",&rows); for(i=1; i<=rows; i++){ //print upper part for(j=1; j<=rows-i; j++){ printf(" ");//print space } for(k=1; k<=i; k++){ printf("%d",k);//print number to upper part printf(" "); } printf("\n"); } for(i=1; i<=rows-1; i++){ //print lower part for(j=1; j<=i; j++){ printf(" ");//print space } for(k=1; k<=rows-i; k++){ printf("%d",k);//print number to lower part printf(" "); } printf("\n");//move to next line } return 0; }
When the above code is executed, it produces the following result
Enter the number of rows: 6 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Similar post
integrated pyramid star pattern in C
integrated pyramid star pattern in Java
C++ code to Double pyramid star pattern
Java code to Double pyramid star pattern
Java program to Display diamond number pattern using while loop
C++ code to Display diamond number pattern using while loop
Floyd’s triangle number pattern using for loop in C
Floyd’s triangle pattern using nested for loop in Java
Floyd’s triangle pattern using nested while loop in Java
Hollow pyramid triangle pattern in C++ language
Rhombus pattern in Java using for loop
Rhombus pattern in C using while loop
Rhombus pattern in C++ using do-while loop
Display Pyramid star pattern in C
Display Pyramid star pattern in Java
Parallelogram and Hollow Parallelogram star pattern in Java
Parallelogram and Hollow Parallelogram star pattern in C Language
C++ program to Display diamond number pattern using while loop
C program to Display diamond number pattern using while loop
Suggested for you
Nested for loop in Java language
Nested for loop in C++ language
Nested for loop in Python language
If statements in Java language
Nested if statements in Java language
Nested while loop in Java language
Nested while loop in C language
Class and main method in Java language
Data type in C++ language