fork download
  1. //Q53. Write a program to print the following pattern:
  2. //*
  3. //***
  4. //*****
  5. //*******
  6. //*********
  7. //*******
  8. //*****
  9. //***
  10. //*
  11. #include <stdio.h>
  12.  
  13. int main() {
  14. int i, j;
  15. int n = 5;
  16. for(i = 1; i <= n; i++) {
  17. for(j = 1; j <= (2*i - 1); j++) {
  18. printf("*");
  19. }
  20. printf("\n");
  21. }
  22.  
  23. for(i = n-1; i >= 1; i--) {
  24. for(j = 1; j <= (2*i - 1); j++) {
  25. printf("*");
  26. }
  27. printf("\n");
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
*
***
*****
*******
*********
*******
*****
***
*