QA 2
Q1: For 123, "three" gets printed, how do I print the rest after figuring the
counter for the number of loops ?
Q2: How do you reverse the order so it reads the number from left to right?
-------------------------------------------------------------------------------
Q1: For 123, "three" gets printed, how do I print the rest after figuring the
counter for the number of loops ?
A1: Since you have the last digit 3 in the loop, keep going in that loop
INCLUDING the switch/if else to print the digit "three". Group the
switch/if else in the loop that extracts each digit.
Now the next loop through will give you 2 -- print "two". ...
-------------------------------------------------------------------------------
Q2: How do you reverse the order so it reads the number from left to right?
A2: This has something to do with "count", the number of iterations for
the loop to divide 123 by ten.
For 123, count is 3.
How do you get the "1" ? Oh divide by 100 (10*10 --> 10 to the 2 power)
How do you get the "2" ? Oh divide by 10 (10 --> 10 to the 1 power)
How do you get the "3" ? Oh divide by 1 (1 --> 10 to the 0 power)
Notice the pattern, how many times you must divide by 10.
For 1234, count is 4.
How do you get the "1" ? Oh divide by 1000 (10*10*10 --> 10 to the 3 power)
How do you get the "2" ? Oh divide by 100 (10*10 --> 10 to the 2 power)
How do you get the "3" ? Oh divide by 10 (10 --> 10 to the 1 power)
How do you get the "4" ? Oh divide by 1 (1 --> 10 to the 0 power)
Think on this, hint another loop.
-------------------------------------------------------------------------------
Q1: For 123, "three" gets printed, how do I print the rest after figuring the
counter for the number of loops ?
Q2: How do you reverse the order so it reads the number from left to right?
-------------------------------------------------------------------------------
Q1: For 123, "three" gets printed, how do I print the rest after figuring the
counter for the number of loops ?
A1: Since you have the last digit 3 in the loop, keep going in that loop
INCLUDING the switch/if else to print the digit "three". Group the
switch/if else in the loop that extracts each digit.
Now the next loop through will give you 2 -- print "two". ...
-------------------------------------------------------------------------------
Q2: How do you reverse the order so it reads the number from left to right?
A2: This has something to do with "count", the number of iterations for
the loop to divide 123 by ten.
For 123, count is 3.
How do you get the "1" ? Oh divide by 100 (10*10 --> 10 to the 2 power)
How do you get the "2" ? Oh divide by 10 (10 --> 10 to the 1 power)
How do you get the "3" ? Oh divide by 1 (1 --> 10 to the 0 power)
Notice the pattern, how many times you must divide by 10.
For 1234, count is 4.
How do you get the "1" ? Oh divide by 1000 (10*10*10 --> 10 to the 3 power)
How do you get the "2" ? Oh divide by 100 (10*10 --> 10 to the 2 power)
How do you get the "3" ? Oh divide by 10 (10 --> 10 to the 1 power)
How do you get the "4" ? Oh divide by 1 (1 --> 10 to the 0 power)
Think on this, hint another loop.
-------------------------------------------------------------------------------