-
Notifications
You must be signed in to change notification settings - Fork 0
/
q27.c
50 lines (48 loc) · 978 Bytes
/
q27.c
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
49
50
// Write a nested for loop to print the following: (In each pass you should print only one character)
// *
// **..
// ***...***
// ****....****....
// *****.....*****.....*****
#include <stdio.h>
int main()
{
int i, j;
for (i = 0; i <= 4; i++)
{
for (j = 0; j <= i; j++)
{
printf("*");
}
if (i > 0)
{
for (j = 1; j <= i + 1; j++)
{
printf(".");
}
}
if (i > 1)
{
for (j = 2; j <= i + 2; j++)
{
printf("*");
}
}
if (i > 2)
{
for (j = 3; j <= i + 3; j++)
{
printf(".");
}
}
if (i > 3)
{
for (j = 4; j <= i + 4; j++)
{
printf("*");
}
}
printf("\n");
}
return 0;
}