Write a program to output Diamond?
Output:-
Note:- You can increase or decrease the size of diamond. For this just change the value of MACRO "PARA"
i.e #define PARA 12
But the value of PARA should be EVEN....
1: #include<stdio.h>
2: #define PARA 12
3: int main() {
4: int i,d;
5: i = (PARA/2);
6: d = (PARA/2);
7: int row,col;
8: for(row = 0 ; row <= (PARA/2) ; row++) {
9: for(col = 0 ; col <= PARA ; col++) {
10: if(col == i || col == d) {
11: printf("*");
12: }
13: else {
14: printf(" ");
15: }
16: }
17: i++;
18: d--;
19: printf("\n");
20: }
21: i = 1;
22: d = (PARA-1);
23: for(row = 0 ; row < (PARA/2) ; row++) {
24: for(col = 0 ; col <= PARA ; col++) {
25: if(col == i || col == d) {
26: printf("*");
27: }
28: else {
29: printf(" ");
30: }
31: }
32: i++;
33: d--;
34: printf("\n");
35: }
36: }
Output:-
Note:- You can increase or decrease the size of diamond. For this just change the value of MACRO "PARA"
i.e #define PARA 12
But the value of PARA should be EVEN....