Half Pyramid in C Programming of Stars using For loop
ADVERTISEMENTS
Half pyramid in C programming of stars using for loop. In this article, you will learn how to print the half pyramid in c programming of stars using for loop.
Source Code
// Half Pyramid in C Programming of Stars using For loop
#include <stdio.h>
int main() {
int r = 0, i, j;
// r - To store the number of rows
printf("-----To print the half pyramid enter the number of rows-----\n");
scanf("%d", &r);
printf("\n");
for (i = 1; i <= r; ++i) {
for (j = 1; j <= i; ++j)
printf("* ");
printf("\n");
}
return 0;
}
Output
-----To print the half pyramid enter the number of rows-----
6
*
* *
* * *
* * * *
* * * * *
* * * * * *