Create Your First Functional Component in React JS – Beginner's Guide
#include <stdio.h>
standard input/output library.
void main()
main function where the program starts.
Variable Declarations
int i, j, r;
r: The number of rows (user input).
i: Controls the outer loop (rows).
j: Controls the inner loop (columns/numbers per row).
printf("enter the number");
scanf("%d", &r);
user to enter an integer value r
the number of rows in the pattern
Outer Loop (Row Control)
for(i = r; i >= 1; i--)
Start from i = r and decrements down to 1.
Each iteration represent one row in the output.
number of values printed in a row equals i.
for(j = 1; j <= i; j++)
{
printf("%d", j);
}
each row, this loop prints numbers starting from 1 up to i.
printf("\n");
row move the cursor to the next line.
return 0;
C Program Print Right Half Character Pyramid Pattern
C program print square star pattern
Comments
Post a Comment