EDIT: looks like the OP got his homework fixed, then did a runner.
Every year (i.e. once per loop) you need to multiply the present balance by 1+i. That's it!
Other things:
- if you loop while n > 0 ... and you never change n ... then you loop for ever.
- you don't need that many variables; you could, in fact, just keep the present balance in p.
Have one variable to hold the present balance. You could actually use p if you wanted; otherwise initialise your present balance variable to p before the loop.
On each pass through the loop ... just multiply your present balance variable by 1+i. THAT ... IS ... IT.
Make sure that your loop runs exactly n times ... not runs indefinitely or breaks out on the first pass because you put a break statement in.