C Online Compiler
Example: Half Pyramid in C Programming of Stars using For loop
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// 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; }
6
Output
Clear
ADVERTISEMENTS