Skip to content

Commit c61112d

Browse files
committed
added: 8-print_square.c
1 parent 9456c53 commit c61112d

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "main.h"
2+
3+
/**
4+
* print_square - draws a square.
5+
*
6+
* @size: size of the square.
7+
*
8+
* Return: Nothing.
9+
*/
10+
void print_square(int size)
11+
{
12+
int height;
13+
int width;
14+
15+
if (size > 0)
16+
{
17+
for (height = 0; height < size; height++)
18+
{
19+
for (width = 0; width < size; width++)
20+
{
21+
_putchar('#');
22+
}
23+
if (height != size - 1)
24+
{
25+
_putchar('\n');
26+
}
27+
}
28+
}
29+
_putchar('\n');
30+
}

0x04-more_functions_nested_loops/main.h

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ void print_most_numbers(void);
77
void more_numbers(void);
88
void print_line(int);
99
void print_diagonal(int);
10+
void print_square(int);

0 commit comments

Comments
 (0)