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 a local variable?

1035


Show the application of a dynamic array with the help of an example.

1074


When do we run a shell in the unix system?

1019


Which programming language's unsatisfactory performance led to the discovery of c++?

1261


What does flush do?

942


What is function prototyping?

1042


Difference between struct and class in terms of access modifier.

1146


What do you understand by a pure virtual member function?

939


What do you mean by inheritance in c++? Explain its types.

1062


What is scope operator in c++?

1036


Can I have a reference as a data member of a class? If yes, then how do I initialise it?

1159


Explain the use of this pointer?

1114


What are inline functions? What is the syntax for defining an inline function?

1084


What is a literal in c++?

1017


What is rtti in c++?

1061