Originally Posted by adityavishnu
hey ,ma idea is to declare p,n,r as global variable and then use it in functions to calculate simple interest and total amount
Yes, you could
do that, but many people think it is a good idea to avoid using global variables as far as possible. And in this case it would not achieve anything as if the user clicked "Final Amount" before clicking "Calculate Interest" then an error would be generated. Can you see why?
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Last edited by Philip M; 11-12-2012 at 11:57 AM..