A

Admin • 833.24K Points
Coach

Q. What is the output of the following C++ code?

Code:
#include <iostream>
using namespace std;
void Sum(int a, int b, int & c)
{
a = b + c;
b = a + c;
c = a + b;
}
int main()
{
int a = 2, b =1;
Sum(a, b, b);
cout << a << " " << b;
return 0;
}
  • (A) 2 1
  • (B) 2 3
  • (C) 2 5
  • (D) 3 5
  • Correct Answer - Option(C)
  • Views: 37
  • Filed under category C++
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.