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

Answers were Sorted based on User's Feedback



int f() { int I = 12; int &r = I; r += r / 4; int *p = &r; *p ..

Answer / 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

int f() { int I = 12; int &r = I; r += r / 4; int *p = &r; *p ..

Answer / guest

ans: 30 i.e 'e'

Is This Answer Correct ?    9 Yes 0 No

Post New Answer

More C++ General Interview Questions

How does code-bloating occur in c++?

0 Answers  


Copy Linked List using recursive function?

2 Answers   Persistent,


What does count ++ do in c++?

0 Answers  


How much do c++ programmers make?

0 Answers  


Do you know what is overriding?

0 Answers  






What is the full form of dos?

0 Answers  


Can non-public members of another instance of the class be retrieved by the method of the same class?

0 Answers  


simple c++ program for "abcde123ba" convert "ab321edcba" with out using string

5 Answers  


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

0 Answers  


Write a program using shift_half( ) function to shift the elements of first half array to second half and vice versa.

0 Answers  


write a program that a 5 digit number and calculates 2 power that number and prints it.

2 Answers   Vimukti Technologies,


A milk carton can hold 3.78 litres of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one litre of milk is $0.38, and the profit of each carton of milk is $0.27. Write a C++ program that prompts the user to enter the total amount of milk produced in the morning. Then display the number of milk cartons needed to hold milk, the cost of producing milk, and the profit for producing milk.

2 Answers  


Categories