130k views
1 vote
What is the output of the following program?

#include
using namespace std; //prototype of function find

void find (int& a, int& b, int c);
int main () {
int a, b, c;
a = 1;
b = 2;
c = 3; //call function find

find (a, b, c);
cout << "first call: " << a << ", " << b << ", " << c << endl; //call function find

find (a, b, c); cout << "second call: " << a << ", " << b << ", " << c << endl; //call function find
find (a, b, c); cout << "third call: " << a << ", " << b << ", " << c << endl; system("pause"); return 0; } //User defined function with reference parameters

void find(int& a, int& b, int c) { a = b + c; b = a + 1; c = b + 2; }

User Yitzchak
by
7.7k points

1 Answer

5 votes

Answer:

The output of the following code:

first call: 5, 6, 3

second call: 9, 10, 3

third call: 13, 14, 3

sh: 1: pause: not found

Step-by-step explanation:

Description to the following method can be described as follows:

  • In the given code, a "Find" method is defined, that accepts three integer parameter, in which two variable is "a and b" is reference variable and c is a normal integer variable.
  • Inside the method, variable a adds "b+c" and in the next line, variable b adds a+1, and invariable c adds b+2.
  • Inside the main method, the find method calls three times and prints its value, for the first time it will print 5, 6, and 3. The second time it will print 9,10, and 3, and in the third time, it will print 13, 14, and 3.
User Nikunj Aggarwal
by
6.2k points