star pattern

C code to print Double pyramid star pattern

C code to print Double pyramid star pattern

In this tutorial, we will discuss a simple concept of te C code to print Double pyramid star pattern

In this post, we will learn how to create double (integrated) pyramid star pattern in C language.

We can use for loop, while loop or do while loop to display different integrated star patterns.

 

Here, we will use for loop to print different Double(integrated) pyramid star patterns

Program 1

Integrated pyramid star 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("*");//print star
}
printf("\n");
}

for(i=rows-1; i>=1; i--){  //print lower part
    for(j=i; j<=rows; j++){
      printf("*");//print star
}
printf("\n");
        }
        getch();
    return 0;
}

When the above code is executed, it produces the following result

Enter the number of rows: 6
******
*****
****
***
**
*
**
***
****
*****
******

 

Program 2

Integrated pyramid star pattern 2

#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(" ");
}
for(k=i; k<=rows; k++){
      printf("*");//print star to upper part
      printf(" ");
}
printf("\n");//move to next line
}

for(i=rows-1; i>=1; i--){  //print lower part
    for(j=1; j<=i; j++){
      printf(" ");
}
for(k=i; k<=rows; k++){
      printf("*");//print star to lower part
      printf(" ");
}
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
*   *   *   *   *   *
  *   *   *   *   *
    *   *   *   *
      *   *   *
        *   *
          *
        *   *
      *   *   *
    *   *   *   *
  *   *   *   *   *
*   *   *   *   *   *

Program 3

Integrated pyramid star pattern 3

#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("*");//print star to upper part
}
printf("\n");//move to next line
}

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("*");//print star to lower part
}
printf("\n");
        }
    return 0;
}

 

When the above code is executed, it produces the following result

Enter the number ofrows: 6
******
  *****
    ****
      ***
        **
          *
        **
      ***
    ****
  *****
******

Program 4

Integrated pyramid star pattern 4

#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(" ");
}
for(k=1; k<=i; k++){
      printf("*");//print star to upper part
      printf(" ");
}
printf("\n");
}

for(i=1; i<=rows-1; i++){  //print lower part
    for(j=1; j<=i; j++){
      printf(" ");
}
for(k=1; k<=rows-i; k++){
      printf("*");//print star to lower part
      printf(" ");
}
printf("\n");
        }
        getch();
    return 0;
}

When the above code is executed, it produces the following result

Enter the number of rows: 6
         *
       *  *
     *  *  *
   *  *  *  *
  *  *  *  * *
*  *  *  *  * *
  *  *  *  *  *
    *  *  *  *
      *  *  * 
        *  *
          *

 

Similar post

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

Pyramid star pattern in Cpp

Pyramid star pattern in C

Pyramid star pattern in Java 

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

For loop in C++ language

For loop in Java language

For loop in C language

For loop in Python language

while loop in C++ language

while loop in Java language

while loop in C language

while loop in Python language

Nested for loop in Java language

Nested for loop in C++ language

Nested for loop in C language

Nested for loop in Python language

 

If statements in Java  language

Nested if statements in Java  language

 

Operator in Java language

Data type in Java language

while loop in Java language

Nested while loop in Java language

Operator in C language

Data type in C  language

variable in C  language

while loop in C language

Nested while loop in C language

input-output function in C

For loop in C language

Nested for loop in C language

 

Print Double pyramid star pattern in Java
Display integrated pyramid star pattern in C using while loop
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

Explanation of one dimensional array (Data structure)

Explanation of one dimensional array In this post, we will discuss the concept of "Explanation…

1 week ago

Python program to calculate the sum of odd and even numbers in a list

Python program to calculate the sum of odd and even numbers in a list In…

2 weeks ago

Python code to Calculate sum of odd and even in a list

Python code to Calculate sum of odd and even in a list In this tutorial,…

2 weeks ago

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

3 weeks ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

1 month ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

2 months ago