The Program in C to Print following shape with the help of loops is given below:
#include <stdio.h>
int main() {
int i, j;
for (i = 1; i <= 5; i++) {
for (j = 1; j <= i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
Output:
*
**
***
****
*****
Pro-Tips💡
This program uses two nested loops to print the shape.
The outer loop iterates from 1 to 5, and the inner loop iterates from 1 to the current value of the outer loop variable.
The program prints an asterisk on each iteration of the inner loop and then goes to the new line after inner loop ends.
This way the program prints the shape.
Learn C-Sharp ↗
C-sharp covers every topic to learn about C-Sharp thoroughly.
Learn C Programming ↗
C-Programming covers every topic to learn about C-Sharp thoroughly.
Learn C++ Programming↗
C++ covers every topic to learn about C-Sharp thoroughly.