Skip to content

Commit 026fde1

Browse files
committed
Solution to task 6
1 parent 0034837 commit 026fde1

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed
16.5 KB
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "main.h"
2+
3+
/**
4+
* main - check the code
5+
*
6+
* Return: Always 0.
7+
*/
8+
int main(void)
9+
{
10+
print_line(0);
11+
print_line(2);
12+
print_line(10);
13+
print_line(-4);
14+
return (0);
15+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <stdio.h>
2+
3+
/**
4+
* print_line - This function draws a straight line on the terminal.
5+
*
6+
* Return: Always 0.
7+
*/
8+
void print_line(int n)
9+
{
10+
int i;
11+
12+
if (n <= 0)
13+
{
14+
putchar('\n');
15+
return;
16+
}
17+
for (i = 0; i < n; i++)
18+
{
19+
putchar('_');
20+
}
21+
putchar('\n');
22+
}

0x04-more_functions_nested_loops/main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ void print_numbers(void);
99
void print_most_numbers(void);
1010
void print_most_numbers(void);
1111
void more_numbers(void);
12+
void print_line(int n);
1213

1314
#endif /* MAIN_H */

0 commit comments

Comments
 (0)