Skip to content

Commit

Permalink
Commit for C - More functions, more nested loops
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWatcher01 committed Oct 21, 2023
1 parent 9534114 commit 9880b67
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions more_functions_nested_loops/6-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "main.h"

/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
print_line(0);
print_line(2);
print_line(10);
print_line(-4);
return (0);
}
20 changes: 20 additions & 0 deletions more_functions_nested_loops/6-print_line.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "main.h"

/**
* print_line - printing lines with underscore
* @n: number of times underscore is printed
*
* Return: void
*/

void print_line(int n) {
if (n <= 0) {
_putchar('\n');
} else {
int i;
for (i = 0; i < n; i++) {
_putchar('_');
}
_putchar('\n');
}
}
1 change: 1 addition & 0 deletions more_functions_nested_loops/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ int mul(int a, int b);
void print_numbers(void);
void print_most_numbers(void);
void more_numbers(void);
void print_line(int n);

0 comments on commit 9880b67

Please sign in to comment.