Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

int f() {
int I = 12;
int &r = I;
r += r / 4;
int *p = &r;
*p += r;
return I;
}
Referring to the sample code above, what is the return value
of the function "f()"?
a) 12
b) 15
c) 24
d) 17
e) 30

Answer Posted / uma sankar pradhan

int I=12;
int &r=I;
here r is a reference to I
r+=r/4;
=>r=r+r/4;
=>r=12+12/4;[r=I=12]
=>r=12+3
=>r=15
=>I=15

int *p=&r;
so, p is a pointer to r(i.e.,to I)

*p +=r;
=>*p = *p+r
=>*p=15+15
=>*p=30
=>I=30

so the return value of the f() is 30

Is This Answer Correct ?    15 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is static class data?

1020


Do you know the use of vtable?

1105


Name the debugging methods that are used to solve problems?

1058


Write a c program for binary addition of two 8 bit numbers.

4077


Explain the static member function.

1139


Why was c++ made?

1059


What are mutator methods in c++?

1131


Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work

1038


How much do c++ programmers make?

1079


Describe new operator and delete operator?

1044


Differentiate between a copy constructor and an overloaded assignment operator.

1038


What is a pointer how and when is it used?

1060


What is a float in c++?

950


What does new return if there is insufficient memory to make your new object?

996


What do you mean by global variables?

1055