Display star pattern based on row (nested for loop)

0
Output

Explanation of the Star Pattern Program

This C program prints a simple star pattern using nested loops. It displays a growing triangle made of the '*' character. Each new row contains one more star than the previous row, forming a staircase-like structure.

The character is stored in a variable and printed repeatedly using loops. The program also uses getch() at the end, which is commonly used in Turbo C to pause the output screen.

What the Program Does

  • Asks the user to enter the number of rows for the pattern.
  • Uses an outer loop to print each row one by one.
  • The inner loop prints the '*' character multiple times depending on the row number.
  • Creates a triangular star pattern.
  • Uses getch() to pause the screen (Turbo C only).

Example Input

Enter the number of row: 5

Example Output

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

Summary: The program prints a triangular star pattern using nested loops. Each row contains a number of stars equal to the row number, forming a visually simple and structured pattern.

Tags

Post a Comment

0Comments

Post a Comment (0)