Mode:
Duration:
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
#include <stdio.h>
int main() {
int i, j, n = 5;
int num = 1;
// Pyramid pattern
for (i = 1; i <= n; i++) {
for (j = 1; j <= n - i; j++)
printf(" ");
for (j = 1; j <= (2 * i - 1); j++)
printf("*");
printf("\n");
}
printf("\n");
// Inverted pyramid
for (i = n; i >= 1; i--) {
for (j = 1; j <= n - i; j++)
printf(" ");
for (j = 1; j <= (2 * i - 1); j++)
printf("*");
printf("\n");
}
printf("\n");
// Floyd’s triangle
for (i = 1; i <= n; i++) {
for (j = 1; j <= i; j++) {
printf("%d ", num);
num++;
}
printf("\n");
}
return 0;
}Coding works best on desktop or with an external keyboard.