forked from swaaz/basicprograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.c
More file actions
48 lines (36 loc) · 923 Bytes
/
Copy pathprogram.c
File metadata and controls
48 lines (36 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// C implementation of the approach
#include <stdio.h>
// Function to print the desired
// Alphabet Z Pattern
void alphabet_Z_Pattern(int N)
{
int index, side_index;
// 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;
}