Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
hollow_diamond_added
Browse files Browse the repository at this point in the history
example-added
  • Loading branch information
kaurjasleen240305 committed Oct 18, 2024
1 parent 5aefa58 commit c0e25bc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Beginner Level 📁/Patterns/HollowDiamond.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <stdio.h>

int main() {
int n;

printf("Enter the height of the diamond: ");
scanf("%d", &n);

for (int i = 1; i <= n; i++) {
for (int j = i; j < n; j++) {
printf(" ");
}
for (int j = 1; j <= (2 * i - 1); j++) {
if (j == 1 || j == (2 * i - 1))
printf("*");
else
printf(" ");
}
printf("\n");
}

for (int i = n - 1; i >= 1; i--) {
for (int j = n; j > i; j--) {
printf(" ");
}
for (int j = 1; j <= (2 * i - 1); j++) {
if (j == 1 || j == (2 * i - 1))
printf("*");
else
printf(" ");
}
printf("\n");
}

return 0;
}
//if n=5
// *
// * *
// * *
// * *
// * *
// * *
// * *
// * *
// *
1 change: 1 addition & 0 deletions Beginner Level 📁/Patterns/questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ Creating Patterns
8.Inverted full pyramid of *
9.Pascal's Triangle
10.Floyd's Triangle
11.Hollow Diamond *

Refernce: programiz.com

0 comments on commit c0e25bc

Please sign in to comment.