C Program to Print Hut Star Pattern

Here is a C program to print a Hut star pattern. Hut star pattern program's output should be:

C program print hut star pattern

Required Knowledge

Algorithm to print hut star pattern
Printing a hut star pattern is a two step process.
  • Step 1: Print pyramid star pattern for top 5 rows. Check this c program to print pyramid star pattern.
  • Step 2: Print the bottom half of the hut. Each row of the bottom half of hut contains 3 stars then three space characters followed by 3 stars.

Here is the matrix representation of the Hut star pattern. The row numbers are represented by i whereas column numbers are represented by j.

C program print hut star pattern

C program to print Hut star pattern on screen


int main() {
    int i, j, space, rows = 8, star = 0;

    /* Printing upper triangle */
    for (i = 0; i < rows; i++) {
        if (i < 5) {
            /* Printing upper triangle */
            for (space = 1; space < 5 - i; space++) {
                printf(" ");
            /* Printing stars */
            while (star != (2 * i + 1)) {
            star = 0;
            /* move to next row */
        } else {
            /* Printing bottom walls of huts */
            for (j = 0; j < 9; j++) {
                if ((int) (j / 3) == 1)
                    printf(" ");
    return 0;
***   ***
***   ***
***   ***

Tips for Writing Hut Star Pattern Printing Programs in C

  • Use Conditional Statements for Shape Definition : Use conditional statements to determine when to print stars and when to print spaces in each row and column, based on the desired hut shape.

  • Use Nested Loops : Use nested loops to print rows and columns of stars in a hut shape. The outer loop controls the number of rows, while the inner loops control the number of stars in each row for different parts of the hut.

  • Experiment with Different Sizes and Designs : Experiment with different sizes and designs of hut shapes to enhance creativity and explore the possibilities of the program.

  • Use Variables for Size and Positioning : Use variables to store the size of the hut and the position of each star, making the program more flexible and easier to modify.

Importance of Practicing Hut Star Pattern Printing Programs for Beginners

  • Understanding of Fundamental Concepts : This program teaches fundamental programming concepts such as loops, conditional statements, and variable manipulation, forming the foundation of programming.

  • Creativity and Innovation : Printing hut star patterns can inspire beginners to think creatively and come up with new ideas for pattern printing and other programming tasks.

  • Building Confidence : Successfully writing and executing this program can boost a beginner's confidence, demonstrating their ability to apply programming concepts in a creative and meaningful way.


In conclusion, the Hut Star Pattern Printing Program in C is a valuable exercise for beginners to enhance their creativity, problem-solving skills, and understanding of fundamental programming concepts. Practicing this program can inspire beginners to think outside the box and develop innovative solutions to programming challenges. By following the tips provided, beginners can effectively write this program and embark on a rewarding journey of creative programming.

Related Topics
C program heart star pattern
C program diamond star pattern
C program rhombus star pattern
C program rectangle star pattern
C program pyramid star pattern
C program multiplication table triangle pattern
C program exponentially increasing star pattern
C program palindrome triangle pattern
C program binary triangle pattern
List of all C pattern programs