-
Notifications
You must be signed in to change notification settings - Fork 0
/
9-times_table.c.old
68 lines (65 loc) · 1.11 KB
/
9-times_table.c.old
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "main.h"
/**
* times_table- output function
*
* Description :'Write a function that prints the 9 times table,
* starting with 0.'
*
* Return: function has no return values
*/
void times_table(void)
{
int ones, multi;
for (ones = 0; ones < 10; ones++)
{
int tens;
for (tens = 0; tens < 10; tens++)
{
multi = ones * tens;
if (multi < 10)
{
if (multi == 0 && (ones == 0 || tens == 0))
{
_putchar(multi % 10 + '0');
if (tens < 9)
{
if (ones == 0)
{
_putchar(',');
_putchar(' ');
_putchar(' ');
}
else if (tens == 0)
{
_putchar(',');
}
}
}
else if (multi < 10 && tens < 9)
{
_putchar(' ');
_putchar(' ');
_putchar(multi % 10 + '0');
_putchar(',');
}
else if (multi == 9 && tens == 9)
{
_putchar(' ');
_putchar(' ');
_putchar(multi % 10 + '0');
}
}
else if (multi > 9)
{
_putchar(' ');
_putchar(multi / 10 + '0');
_putchar(multi % 10 + '0');
if (tens < 9)
{
_putchar(',');
}
}
}
_putchar('\n');
}
}