fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int i,j, rows;
  5.  
  6. printf("Enter the number of rows\n");
  7. scanf("%d", &rows);
  8. /* printing top semi circular shapes of heart */
  9. for(i = rows/2; i <= rows; i+=2){
  10. /* Printing Spaces */
  11. for(j = 1; j < rows-i; j+=2) {
  12. printf(" ");
  13. }
  14. /* printing stars for left semi circle */
  15. for(j = 1; j <= i; j++){
  16. printf("*");
  17. }
  18. /* Printing Spaces */
  19. for(j = 1; j <= rows-i; j++){
  20. printf(" ");
  21. }
  22. /* printing stars for right semi circle */
  23. for(j = 1; j <= i; j++){
  24. printf("*");
  25. }
  26. /* move to next row */
  27. printf("\n");
  28. }
  29.  
  30. /* printing inverted start pyramid */
  31. for(i = rows; i >= 1; i--){
  32. for(j = i; j < rows; j++){
  33. printf(" ");
  34. }
  35. for(j = 1; j <= (i*2)-1; j++){
  36. printf("*");
  37. }
  38. /* move to next row */
  39. printf("\n");
  40. }
  41.  
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0s 5276KB
stdin
7
stdout
Enter the number of rows
  ***    ***
 *****  *****
**************
*************
 ***********
  *********
   *******
    *****
     ***
      *