A pattern program in the C language is quite an easy and fun way to practice loops as well as logical thinking. Pattern program just means printing different shapes like pyramid, triangle, diamond, star, alphabets, and numbers using C code.
Learning this pattern program in C will help you understand clearly how nested loops and different conditions work. Such types of programs are mostly used in coding interviews, programming competitions, and also college tests, logic as well and coding skills.


Below are easy ways to print patterns clearly and step by step. This just makes it simple for beginners to master the art of C programming and gain great knowledge.
Program code :
#include
int main() {
int i, j, rows = 5;
for(i = 1; i <= rows; i++) { for(j="1;" j <="i;" j++) printf("*"); } printf("\n"); return 0; output : * ** *** **** ***** pre>
=> Explanation of code :
Program code :
#include
int main() {
int i, j, rows = 5;
for(i = rows; i >= 1; i--) {
for(j = 1; j <= i; j++) { printf("*"); } printf("\n"); return 0; output : ***** **** *** ** * < pre>
=> Explanation of code :
Program code :
#include
int main() {
int i, space, j, rows = 5;
for(i = 1; i <= rows; i++) { for(space="1;" space <="rows-i;" space++) printf(" "); for(j="1;" j j++) printf("*"); printf("\n"); } return 0; output : * *** ***** ******* ********* pre>
=> Explanation of code :
Program code :
#include
int fact(int n) {
if(n==0) return 1;
else return n*fact(n-1);
}
int main() {
int i, j, rows = 5;
for(i = 0; i < rows; i++) {
for(j = 0; j <= 1 2 3 4 6 rows-i-1; j++) printf(" "); for(j="0;" j <="i;" printf("%d ", fact(i) (fact(j)*fact(i-j))); printf("\n"); } return 0; output : pre>
=> Explanation of code :
Program code :
#include
int main() {
int i, j, rows = 5;
for(i = 1; i <= 1 rows; i++) { for(j="i;" j < j++) printf(" "); if(i="=" rows || (2*i-1)) printf("*"); else } printf("\n"); return 0; output : * ********* pre>
=> Explanation of code :
Program code :
#include
int main() {
int i, j, rows = 5;
for(i = 1; i <= 1 2 3 4 5 rows; i++) { for(j="1;" j <="i;" j++) printf("%d ", j); } printf("\n"); return 0; output : pre>
=> Explanation of code :
Program code :
#include
int main() {
int i, j, rows = 5;
char ch;
for(i = 1; i <= rows; i++) { ch="A" ; for(j="1;" j <="i;" j++) printf("%c ", ch++); } printf("\n"); return 0; output : a b c d e pre>
=> Explanation of code :
Program code :
#include
int main() {
int rows = 5, i, j, space;
for (i = rows; i >= 1; i--) {
for (space = 1; space <= rows - i; space++) printf(" "); for (j="1;" j <="2" * i 1; j++) printf("*"); printf("\n"); } return 0; output : ********* ******* ***** *** pre>
=> Explanation of code :
Program code :
#include
int main() {
int rows = 5, i, j;
for (i = 1; i <= rows; i++) { for (j="1;" j <="i;" j++) printf("*"); printf("\n"); } return 0; output : * ** *** **** ***** pre>
=> Explanation of code :
Program code :
#include
int main() {
int rows = 5, i, j, space;
// Upper half
for(i = 1; i <= rows; i++) { for(space="1;" space <="rows" - i; space++) printf(" "); for(j="1;" j 1; j++) printf("*"); printf("\n"); } lower half for(i="rows" i>= 1; i--) {
for(space = 1; space <= rows - i; space++) printf(" "); for(j="1;" j <="2*i" 1; j++) printf("*"); printf("\n"); } return 0; output : * *** ***** ******* ********* pre>
=>=> Explanation of code :
Program code :
#include
int main() {
int i, j, space, n = 5;
// Upper half
for(i = n; i >= 1; i--) {
for(space = 0; space < n - i; space++)
printf(" ");
for(j = 1; j <= (2 * i - 1); j++) printf("*"); printf("\n"); } lower half for(i="2;" <="n;" i++) { for(space="0;" space n i; space++) printf(" "); for(j="1;" j return 0; output : ********* ******* ***** *** pre>
=> Program code :
#include
int main() {
int n = 7; // Change to any odd number >=3
int i, j, min;
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
min = i < j ? i : j;
min = min < n - i ? min : n - i - 1;
min = min < n - j - 1 ? min : n - j - 1;
if (min % 2 == 0)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}
Output ( For n = 7 )
*******
* *
* *** *
* * * *
* *** *
* *
*******
Conclusion (150 words)
Star pattern programs in C are more than just beginner exercises—they build a strong foundation in logic, loops, conditionals, and spatial reasoning. Through complex patterns like the concentric square design, learners gain exposure to real-world applications such as UI design layouts, radar systems, and data layer traversal in matrix operations. These programs sharpen problem-solving skills and improve code optimization techniques.
Additionally, patterns help in mastering nested loops, coordinate mapping, and creative algorithm design, which are essential in technical interviews and competitive coding. Real-life relevance makes these patterns not only fun but also practical learning tools. Whether you're preparing for exams or cracking coding rounds, mastering star patterns equips you with a structured thought process to tackle larger programming challenges. As you progress to more intricate patterns and algorithms, you'll appreciate how these visual, structured programs lay the groundwork for advanced logic building and software development. Keep practicing and experimenting!
Enroll in a C programming course in Noida to get detailed training information and knowledge about these trending patterns. You can easily crack your dream job with the help of that.
Personalized learning paths with interactive materials and progress tracking for optimal learning experience.
Explore LMSCreate professional, ATS-optimized resumes tailored for tech roles with intelligent suggestions.
Build ResumeDetailed analysis of how your resume performs in Applicant Tracking Systems with actionable insights.
Check ResumeAI analyzes your code for efficiency, best practices, and bugs with instant feedback.
Try Code ReviewPractice coding in 20+ languages with our cloud-based compiler that works on any device.
Start Coding
TRENDING
BESTSELLER
BESTSELLER
TRENDING
HOT
BESTSELLER
HOT
BESTSELLER
BESTSELLER
HOT
POPULAR