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
πŸ’¬ Discuss
βœ… Correct Answer: (C) 2 5

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
274
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
96%
Success Rate