-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmario.c
More file actions
38 lines (35 loc) · 795 Bytes
/
mario.c
File metadata and controls
38 lines (35 loc) · 795 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
36
37
38
#include <stdio.h>
#include <cs50.h>
int get_positive_int(string prompt);
int main(void)
{
int height;
//getting value of hihgt
height = get_positive_int("Height: ");
//main cycle for new lines
for (int enters = 0; enters < height; enters++)
{
//cycle for typing spaces
for (int spaces = height - 1; spaces > enters; spaces--)
{
printf(" ");
}
//cycle for typing hashes
for (int hashes = -1; hashes < enters; hashes++)
{
printf("#");
}
printf("\n");
}
}
//function for getting only positive integer from 1 to 8 from user
int get_positive_int(string prompt)
{
int n;
do
{
n = get_int("%s", prompt);
}
while (n < 1 || n > 8);
return n;
}