Skip to content

Commit

Permalink
9-times_table.c
Browse files Browse the repository at this point in the history
  • Loading branch information
victorpreston committed Jun 20, 2023
1 parent ff038e3 commit 879432b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions 0x02-functions_nested_loops/9-times_table.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "main.h"

/**
* times_table - check description
* Description: It prints 9 times table starting with 0
* Return: Nothing.
*/
void times_table(void)
{
int i, j, n;

for (i = 0; i <= 9; i++)
{
for (j = 0; j <= 9; j++)
{
n = i * j;

if ((n / 10) == 0)
{
if (j != 0)
_putchar(' ');
_putchar(n + '0');

if (j == 9)
continue;
_putchar(',');
_putchar(' ');
}
else
{
_putchar((n / 10) + '0');
_putchar((n % 10) + '0');
if (j == 9)
continue;
_putchar(',');
_putchar(' ');
}
}
_putchar('\n');
}
}

0 comments on commit 879432b

Please sign in to comment.