• retagged by
236 views
1 1 vote

Consider the following C++ program:

#include
using namespace std;
void modify(int &a, int &b, int &c)
{
    a = 2;
    b = 6;
    c = 14;
}
int main()
{
    int x = 1, y = 3, z = 7;
    modify(x, y, z);
    cout << x << " " << y << " " << z;
    return 0;
}



What will be the output of the program?
 

  1. $1 \ 3 \ 7$
     
  2. $2 \ 6 \ 14$
     
  3. $2 \ 3 \ 7$
     
  4. Compilation error

 

1 Answer

0 0 votes
Answer will be A since it is call by value . All changes that happens within modify function only . When you complete execution of modify function the value of 1 3 7
Answer:
Position:
Show:

Related questions

2 2 votes
1 1 answer
358
358 views
GO Classes asked Mar 17
358 views
Size of $\verb|int|$ is $\mathrm{2~B}$ and size of $\verb|float|$ is $\mathrm{4~B}$Consider the following C++ program:#include<iostream using namespace std; int main() { ...
1 1 vote
1 1 answer
236
236 views
GO Classes asked Mar 17
236 views
Consider the following C++ program:#include using namespace std; template void func(T x) { static int count = 0; cout << x << " " << ++count << endl; } int main()...
0 0 votes
0 0 answers
201
201 views
GO Classes asked Mar 17
201 views
Which of the following is false about Operator Overloading in C++$\texttt{::}$ operator cannot be overloaded A unary operator can be overloaded to act as a binary operat...
1 1 vote
0 0 answers
397
397 views
GO Classes asked Mar 17
397 views
Consider the following C program:#include <stdio.h void func(int *a, int *b) { int i = (*a) * (*b); int *j = b; for (;;) { if (i 20) ...