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
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 |
Write a Program to find the largest of 4 no using macros.
Tell me can a pure virtual function have an implementation?
How can we read/write Structures from/to data files?
Given a simple program designed to take inputs of integers from 1-1000 and to output the factorial value of that number, how would you test this program? You do not have access to the code. Please be as specific as possible.
What are the new features that iso/ansi c++ has added to original c++ specifications?
which operator is used for performing an exponential operation a) > b) ^ c) none
What do manipulators do?
write a program that takes two numbers from user that prints the smallest number
What is guard code in c++?
Which bit wise operator is suitable for putting on a particular bit in a number?
What are the weaknesses of C++?
What is the difference between static link library and dynamic link library?