what's the problem with this program? http://dpaste.com/911626/
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
one quick hint: your outstandingbalance is created after the for loop...so it doesnt know how much that is till it finisces the for loop....(after 12 rounds)
your implementation is all wrong i believe...
u define your function (main) but u call it after the spot u actually need it.....
try calling it before the for loop and see what happens...
plus: in the end you are printing the word "RESULT" why?!
I would recommend one or two blank lines to separate your function from your main code. That will give a much different perspective on what the program is really doing.
During debugging, I frequently print the value of variables at different points to try to find the problem, and then take the print statements out when it starts running.
Not the answer you are looking for? Search for more explanations.
hey here are some suggestions
1. you don`t actually need a main() function because what you are doing is taking i as an argument and returning it back besides taking some inputs so rather don`t use main() or do all your calculations in the main() itself.
2. as pointed out do separate your functions from the other code
3. just printing RESULT on the screen won`t do rather print in the more information that is required as an output
4. as a good programming practice try and name your functions that are easy to understand just by reading the name e.g you could name it balance() or card_balance something of this sort.
5. at this stage your best debugging tool is print statements. if you don`t get your answer try introducing print statements to check what you expected and what you got back from the machine.