diff --git "a/Beginner Level \360\237\223\201/Patterns/HollowDiamond.c" "b/Beginner Level \360\237\223\201/Patterns/HollowDiamond.c" new file mode 100644 index 00000000..e42a0374 --- /dev/null +++ "b/Beginner Level \360\237\223\201/Patterns/HollowDiamond.c" @@ -0,0 +1,46 @@ +#include + +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 +// * +// * * +// * * +// * * +// * * +// * * +// * * +// * * +// * \ No newline at end of file diff --git "a/Beginner Level \360\237\223\201/Patterns/questions.md" "b/Beginner Level \360\237\223\201/Patterns/questions.md" index d17ed5dc..9074901f 100644 --- "a/Beginner Level \360\237\223\201/Patterns/questions.md" +++ "b/Beginner Level \360\237\223\201/Patterns/questions.md" @@ -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 \ No newline at end of file