From ab3be0cd2ad8ca2401567108b38a7ceb6a9fb063 Mon Sep 17 00:00:00 2001 From: sharan sk <46704651+sharansk792000@users.noreply.github.com> Date: Sat, 12 Oct 2019 23:29:57 +0530 Subject: [PATCH] Create program.c --- C/program-44/program.c | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 C/program-44/program.c diff --git a/C/program-44/program.c b/C/program-44/program.c new file mode 100644 index 00000000..24dbbcb7 --- /dev/null +++ b/C/program-44/program.c @@ -0,0 +1,48 @@ +// C implementation of the approach +#include + +// Function to print the desired +// Alphabet Z Pattern +void alphabet_Z_Pattern(int N) +{ + int index, side_index, size; + + // Declaring the values of Right, + // Left and Diagonal values + int Top = 1, Bottom = 1, Diagonal = N - 1; + + // Loop for printing the first row + for (index = 0; index < N; index++) + printf("%d ", Top++); + + printf("\n"); + + // Main Loop for the rows from (2 to n-1) + for (index = 1; index < N - 1; index++) { + + // Spaces for the diagonals + for (side_index = 0; side_index < 2 * (N - index - 1); + side_index++) + printf(" "); + + // Printing the diagonal values + printf("%d", Diagonal--); + + printf("\n"); + } + + // Loop for printing the last row + for (index = 0; index < N; index++) + printf("%d ", Bottom++); +} + +// Driver Code +int main() +{ + // Size of the Pattern + int N = 5; + + alphabet_Z_Pattern(N); + + return 0; +}