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

Is swift a good first language?

1096


Difference between a copy constructor and an assignment operator.

1051


Explain operator overloading.

1109


Is there any function that can skip certain number of characters present in the input stream?

1129


which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?

1238


Explain how to initialize a const data member.

1179


Does c++ vector allocate memory?

1063


Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?

1188


What is an iterator class in c++?

1199


Define a pointer to a data member of the type pointer to pointer?

1041


How do you add an element to a set in c++?

1036


What are arrays c++?

1148


When is the destructor called?

1087


Is c++ a software?

1247


Which one is a preferred language C or C++? Why?

1147