GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  TCS  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 22 of 87    Print  
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
B



  
Total Answers and Comments: 2 Last Update: September 02, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
February 10, 2006 16:58:34   #1  
laxmikanth        

RE: what does the following code do?fn(int n,int p...

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.


 
Is this answer useful? Yes | No
September 01, 2007 14:16:37   #2  
SATNAM WADHWA        

RE: what does the following code do?fn(int n,int p...
The code simply calculates the compound interest for max four years
It is so bcoz of absence of break statement in the switch.

 
Is this answer useful? Yes | No

 Related Questions

What is false about the following A compound statement is a.A set of simple statmentsb.Demarcated on either side by curly bracketsc.Can be used in place of simple statementd.A C function is not a compound statement.

Which of the following about automatic variables within a function is correct ?a.its type must be declared before using the variableb.they are localc.they are not initialised to zerod.they are global.

Write one statement equivalent to the following two statementsx=sqr(a);return(x);Choose from one of the alternativesa.return(sqr(a));b.printf("sqr(a)");c.return(a*a*a);d.printf("%d",sqr(a));

Latest Answer : Here the statement if(x=6) is true because this is not a conditional operator it assigns 6 to x so it is true, the if condition is truethen y=7; ...

Read the folllowing code# define MAX 100# define MIN 100........if(x>MAX)x=1;else if(x

A memory of 20 bytes is allocated to a string declared as char *sthen the following two statements are executed:s="Etrance"l=strlen(s);what is the value of l ?a.20b.8c.9d.21

Given the piece of codeint a[50];int *pa;pa=a;to access the 6th element of the array which of the following is incorrect?a.*(a+5)b.a[5]c.pa[5]d.*(*pa + 5)

Regarding the scope of the varibles;identify the incorrect statement:a.automatic variables are automatically initialised to 0b.static variables are are automatically initialised to 0c.the address of a register variable is not accessiabled.static variables cannot be initialised with any expression

Latest Answer : I think value of y = 5.Because if you format the code, it will look like thisx = 10;y=5;if (x==10){}else if(x==9){}else{   y=8;}Since value of x is 10 so condition if (x==10) will satisfy. And there is no assignment for y. So value of y ...

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


 Sponsored Links

 
Related Articles

How to Best Use Business Intelligence to Your Advantage

How to Best Use Business Intelligence to Your Advantage It is no big secret that today s businesses rely heavily on data and the information it delivers about their companies Whether it is for the purpose of customer acquisition improving operational performance or understanding competitors all of t
 

Taking Advantage of Standard Internet Protocols

Taking Advantage of Standard Internet Protocols As mentioned Oracle XML DB provides native support for standard internet protocols such as S WebDAV and Continuing with the preceding sample you might for example upload another employee XML document into the XML repository with one of the above prot
 

Accessing Repository Resources with SQL

Accessing Repository Resources with SQL In fact Oracle XML DB repository resources are stored in a set of database tables and indexes which can be accessed via SQL You are not supposed to access those tables directly Instead Oracle XML DB provides two public views RESOURCE VIEW and PATH VIEW through
 

jQuery Table Row Finished Code

jQuery Table Row Finished Code The Finished Code Our second example page has demonstrated table row striping highlighting tooltips collapsing expanding and filtering Taken together the JavaScript code for this page is mosgoogle geshibot lang php" document ready function var highlighted
 

jQuery Interacting with Other Code

jQuery Interacting with Other Code We learned with our sorting and paging code that we can t treat the various features we write as islands The behaviors we build can interact in sometimes surprising ways; for this reason it is worth revisiting our earlier efforts to examine how they coexist with t
 

jQuery Alternating Triplets

Learning jQuery Alternating Triplets Suppose we want to use two colors but have each one display three rows at a time For this we can employ the odd and even classes again as well as the modulus operator But we ll also reset the class each time we re presented with a row containing th> elem
 

jQuery Three-color Alternating Pattern

Learning jQuery Three color Alternating Pattern There may be times when we want to apply more complex striping For example we can apply a pattern of three alternating row colors rather than just two To do so we first need to define another CSS rule for the third row We ll also reuse the odd and even
 

jQuery Advanced Row Striping

Learning jQuery Advanced Row Striping As we saw earlier in the chapter row striping can be as simple as two lines of code to alternate the background color mosgoogle geshibot lang php" document ready function table sortable tbody tr odd addClass odd ; table sortable tbody tr even addC
 

jQuery Completed sorting and paging code

Learning jQuery The Finished Code The completed sorting and paging code in its entirety follows mosgoogle geshibot lang php" fn alternateRowColors function tbody tr odd this removeClass even addClass odd ; tbody tr even this removeClass odd addClass even ; return this; ; document
 

jQuery - Basic Alphabetical Sorting

Learning jQuery Basic Alphabetical Sorting Now let s perform a sort on the Title column of the table We ll need a class on the table header cell so that we can select it properly geshibot lang html" Title Author s Publish Date Price geshibot mosgoogle To perform the actual s
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape