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

Code:
#include <iostream>
using namespace std;
double & getVal()
{
  double v = 12.99;
  double &val = v;
  return val;
}
int main()
{
  double v = getVal();
  cout << "The value = " << v;
  return 0;
}
  • (A) 12
  • (B) 12.99
  • (C) Compilation error
  • (D) None of these
πŸ’¬ Discuss
βœ… Correct Answer: (B) 12.99

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

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