-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmario.c
More file actions
35 lines (28 loc) · 670 Bytes
/
mario.c
File metadata and controls
35 lines (28 loc) · 670 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
#include <cs50.h>
#include <stdio.h>
#include <unistd.h>
void print(char x, int h); // data and function prptotype
int main(void)
{
int h;
do
{
h = get_int("Height? : "); //get hight input from user.
}
while (1 > h || h > 8); //ask for right value.
for (int j = 0; j < h; j++) // main loop
{
print(' ', h - 1 - j); // starting spaces.
print('#', j + 1); // 1st pyramid bricks.
print(' ', 2); //middle.
print('#', j + 1); // 2 nd pyramid.
printf("\n"); // new line.
}
}
void print(char x, int h)
{
for (int j = 0; j < h; j++)
{
printf("%c", x);
}
}