-
Notifications
You must be signed in to change notification settings - Fork 0
/
Diamond
46 lines (34 loc) · 858 Bytes
/
Diamond
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
/* Humza Khawar
Diamond
*/
#include <stdio.h>
int main()
{
int num, space, row;
do
{
printf("Enter number of rows\n");//checks for odd number
scanf_s("%d", &num);
} while (num%2==0);
for (row = 1; row <= num/2+1 ; row++)//loop for row
{
for (space = 1; space <= num - row; space++)//loop for space
printf(" ");
for (space = 1; space <= 2 * row-1 ; space++)//loop for printing *
printf("*");
printf("\n");
}
for (row; row <= num; row++)//loop for row
{
for (space = 1; space < row; space++)//loop for space
{
printf(" ");
}
for (space = 0; space <= 2*(num-row); space++)//loop for printing *
{
printf("*");
}
printf("\n");
}
return 0;
}