Skip to content
Home » C Programs » Half Diamond Star Pattern in C

Half Diamond Star Pattern in C

Basic half diamond star pattern in c for beginners. Pattern programs are simply patterns made up of integers, alphabets, or symbols in a specific order. The for loop condition can be used to solve these types of pattern programs quickly.

For Loop Definition in C

A for loop is a repetition control structure that allows us to create a loop that runs a set number of times. The loop allows us to do an arbitrary number of steps in a single line. A loop is used to repeatedly execute a set of statements until a certain condition is met.

\n or New Line in C Program

It’s known as “newline.” You can’t put it directly in the string because that would add a new line to the source code, but you can do it with n inside quotes in C. You could instead use puts instead of printf, which produces a new line after the string.

Half Diamond Star Pattern in C

#include <stdio.h> 
void main() 
{ 
int i, j, rows; 
printf (" Enter the number of rows\n "); 
scanf("%d", &rows); 
printf("\n"); 
for (i = 1; i <= rows; ++i) 
{ 
for (j = 1; j <= i; ++j) 
{ 
printf ("* "); 
} 
printf ("\n"); 
} 
} 

Output:

*
* *
* * *
* * * *
* * * * *