Ask your own question, for FREE!
Mathematics 21 Online
OpenStudy (anonymous):

Write a program to display multiplication table from two to nine for example: 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 = 10 2 x 6 = 12 2 x 7 = 14 2 x 8 = 16 2 x 9 = 18 2 x 10 = 20

OpenStudy (anonymous):

okay, this is pretty straight forward. here's some Java-like pseudocode: accumulator = 0; for (n = 1; n <= 9; ++n) { accumulator += 2; print("2 x " + n + " = " + accumulator); }

OpenStudy (anonymous):

i don't understand accumulator

OpenStudy (anonymous):

Ok thank

OpenStudy (anonymous):

accumulator increments by 2 each iteration so for n = 1 it'll be 2 then for n = 2 it'll be 2 + 2 = 4 then for n = 3 it'll be 4 + 2 = 6 then for n = 4 it'll be 6 + 2 = 8

OpenStudy (anonymous):

since we're iterating thru all the products it's cheaper to just keep adding 2 than to multiply 2 * n separately each time

OpenStudy (anonymous):

Ok i'm testing ....

OpenStudy (anonymous):

http://ideone.com/w1eVqo

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!