reset password
Author Message
SierraMountain89
Posts: 3
Posted 23:14 May 04, 2016 |

     Hello,

        I tested out the code for Lab 4, Problem 1. I entered the number 234567890876543456789087654345678987654345, but I obtained a sum of 861 instead. 

Last edited by SierraMountain89 at 23:28 May 04, 2016.
aalva190
Posts: 64
Posted 23:28 May 04, 2016 |

a

First thing first, i dont think your allowed to even show your whole code. Something keenan told us not to do, and secondly, did you try debugging by hand? i am sure you will see your problem if you try small numbers like numbers 1 -3. Best way to check by your self. and finally. 

you can do do this all in one for loop rather then using two loops with while loop and for loop. 

Hint check page 159 in the book, it should be something smiliar to that. 

Last edited by aalva190 at 23:29 May 04, 2016.
aalva190
Posts: 64
Posted 23:34 May 04, 2016 |

The answer should be similar to page 159 but since this is a large number you must convert the string, like he showed us. It looks like you correctly did converted the string to an interger, so thats one step closer, the rest should be the same as page 159

 Hopefully that helped. Just let me know if you have other questions. 
 

SierraMountain89
Posts: 3
Posted 23:52 May 04, 2016 |

       I gave this my best shot. Thank you for the helpful comments.