A
for
statement has four parts:
for (a ; b ; c )
d;
Where:
a
is executed before the loop starts
c
is executed after the loop has run
b
is tested after c has executed
d
is executed each time the loop runs.
In pseudo code it looks like this:
1) Execute
a
2) If ( not
b
) goto (3)
2.1) Execute
d
2.2) Execute
c
2.3) Goto (2)
3) done.
So in your case:
1) Subtract one from
digit
2) if ( digit < 0 ) exit the loop.
2.1) Execute these lines:
nextDigit = convertedNumber[digit];
printf ("%c", baseDigits[nextDigit]);
2.2) Subtract one from
digit
2.3) Loop round to (2) and check again.
The other code fragment is simple:
baseDigits
is an array, and your code
baseDigits[nextDigit]
extracts the element at the position given by the index value in
nextDigit
- so if the index is zero, it fetches the first character '0', if it's one it fetches '1', and so on up to fourteen 'E' and fifteen 'F'
You wrote this code for your homework, so you should really understand what it does...