C Program
C Program To Print Rhombus Star Pattern
Example
C Program To Print Rhombus Star Pattern
Explain Program
Step :1
#include <stdio.h>
input/output library to printf() and scanf().
Step :2
int main()
every C program. Execution starts
Step :3
int i, j, rows;
Variable declarations:
rows: Number of rows for the rhombus
Step :4
printf("Enter rows: ");
scanf("%d", &rows);
user to input an integer (rows)
Step :5
for(i = 1; i <= rows; i++)
Outer loop control the number of rows to be printed.
It runs from 1 to rows.
iteration prints one row of the rhombus.
Step :6
for(j = 1; j <= rows - i; j++)
{
printf("
");
}
This inner loop prints spaces before the stars on each line.
Step :7
for(j = 1; j <= rows; j++)
{
printf("*");
}
loop prints a fixed number of stars: exactly rows stars
on each line.
Step :8
printf("\n");
next line after printing .
Program Exit:
return 0;
C Program To Print Rhombus Star Pattern
No comments:
Post a Comment