IN C++ PROGRAM: struct point {char c; int x; int y; }; void display (point * k)
ID: 3695005 • Letter: I
Question
IN C++ PROGRAM:
struct point {char c; int x; int y; };
void display (point * k)
{ cout << " Coordinates of point " << k -> c << " are " << k -> x << " and " << k -> y << " "; }
int main() { point s; s.c = 'M'; s.x = 3; s.y = 4; display(&s);
system("pause") ;
return 0;}
In the code snippet above, the structure point M is initialized (3, 4) and displayed (as: coordinates of M are 3 and 4) passing the argument by
A) value
B) reference
C) address
D) void
Explanation / Answer
C) its pass by address
Pass By Address allows us to change the original argument of a function (like with Pass By Reference). Don't pass in the argument itself -- just pass in its address.