What does the following code do?fn(int n,int p,int r){static int a=p;switch(n){case 4:a+=a*r;case 3:a+=a*r;case 2:a+=a*r;case 1:a+=a*r;}}a.computes simple interest for one yearb.computes amount on compound interest for 1 to 4 yearsc.computes simple interest for four year d.computes compound interst for 1 year

B
This question is related to TCS Interview

Showing Answers 1 - 2 of 2 Answers

laxmikanth

  • Feb 10th, 2006
 

None of the answers is correct Bcos we are not all calculating interest instead we are caluculating the total amount for 1 year under simple interest with rate of interest is already converted into decimal form.

Eg:if rate of interest is some 6% then her  it is taken  as 0.06.

  Was this answer useful?  Yes

SATNAM WADHWA

  • Sep 1st, 2007
 

The code simply calculates the compound interest for max four years
It is so bcoz of absence of break statement in the switch.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions