fork download
  1. /*
  2. Print the following pattern
  3. *
  4. **
  5. ***
  6. ****
  7. *****
  8. */
  9. #include <stdio.h>
  10.  
  11. void print_pyramid(int rows) {
  12. for (int i = 1; i <= rows; i++) {
  13. for (int j = 1; j <= i; j++) {
  14. printf("*");
  15. }
  16. printf("\n");
  17. }
  18. }
  19.  
  20. int main() {
  21. int rows = 5;
  22. print_pyramid(rows);
  23. return 0;
  24. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
*
**
***
****
*****