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 year
b.computes amount on compound interest for 1 to 4 years
c.computes simple interest for four year
d.computes compound interst for 1 year

Answers were Sorted based on User's Feedback



what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){..

Answer / vikraman85

Here a is declared as static,so it can't be re-initialized..

Is This Answer Correct ?    4 Yes 1 No

what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){..

Answer / subbu

gives an error because at the time of initialization we
should not use variables, we can use only constants at the
time of initialization.

Is This Answer Correct ?    4 Yes 3 No

what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){..

Answer / vignesh1988i

this code depends upon the value of 'n' actually....... if
the value is 4 the operation is differewnt... if 3 its
different..... so give the value of 'n'!

Is This Answer Correct ?    3 Yes 2 No

what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){..

Answer / deepali

b

Is This Answer Correct ?    2 Yes 1 No

what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){..

Answer / eswaran

initializer is a constant value..so its not possible to
change the value at run time..

Is This Answer Correct ?    1 Yes 0 No

what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){..

Answer / mani thangaraj

I feel it as d.computes compound interest for one
year.because of switch statement any one of the four gets
executed .. and it seems to be C.I

Is This Answer Correct ?    0 Yes 0 No

what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){..

Answer / nila

d.computes compound interest for 1 year

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

how logic is used

0 Answers  


What is Your Name :)

1 Answers  


What is the use of getch ()?

0 Answers  


What is bin sh c?

0 Answers  


write a program to find out prime number using sieve case?

0 Answers   HCL,






output for following code??? main() { int x=2,y,z; x*=3+2; printf("1.%d\n",x); x*=y=z=4; printf("2.%d %d %d\n",x,y,z); x=y==z; printf("3.%d\n",x); x==(y=z); printf("%d",x); }

2 Answers   Elysium,


in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

0 Answers   TCS,


Which one would you prefer - a macro or a function?

0 Answers  


Which is more efficient, a switch statement or an if else chain?

0 Answers  


What is a char c?

0 Answers  


What does return 1 means in c?

0 Answers  


What are the types of assignment statements?

0 Answers  


Categories