Search This Blog
Welcome to 1printf(), your ultimate destination for C, C++, Linux, Data Structures, and Microcontroller programming! 🚀 🔹Learn advanced coding techniques in C& C++ 🔹Master Linux internals & shell scripting 🔹Deep dive into Data Structures & Algorithms 🔹Explore Embedded Systems & Microcontrollers (8051,UART, RTOS) 🔹Get hands-on coding tutorials, project ideas,and interview preparation tips Whether you're a beginner or an experienced programmer, this channel will help you
Featured
- Get link
- X
- Other Apps
Dual Half Pyramid Star Pattern in C
Inverted and Upright Half Pyramid in C
This C program prints a symmetrical V-shaped pattern using asterisks (*). It first prints an inverted half pyramid followed by a normal half pyramid using nested for loops.
✅ C Program Code:
#include <stdio.h>
int main()
{
int num;
printf("Enter the number:\n");
scanf("%d", &num);
// Inverted half pyramid
for (int i = 1; i <= num; i++)
{
for (int j = i; j <= num; j++)
{
printf("* ");
}
printf("\n");
}
// Upright half pyramid
for (int i = 1; i <= num; i++)
{
for (int j = i; j >= 1; j--)
{
printf("* ");
}
printf("\n");
}
}
💡 Explanation:
- The first loop prints the inverted half pyramid (top part) with decreasing number of stars.
- The second loop prints the upright half pyramid (bottom part) with increasing number of stars.
- This creates a V-shaped pattern using asterisks.
💻 Sample Output:
4
* * * *
* * *
* *
*
*
* *
* * *
* * * *
🔍 Keywords:
Star pattern in C, V star pattern, inverted pyramid in C, C pattern practice, nested loops C programs, symmetric pattern using C
Popular Posts
C++ Program for Hybrid Inheritance (All Types Together)
- Get link
- X
- Other Apps
C++ Program for Function Overloading Example
- Get link
- X
- Other Apps

Comments
Post a Comment