Question discussion

What is the output of the following C++ program?#include using namespace std; int f(int a, int b = 5) { return a * b; } int f(double a) { r…

1108Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following C++ program?

#include <iostream>
using namespace std;
int f(int a, int b = 5) { return a * b; }
int f(double a) { return 7; }
int main() { cout << f(3) << f(2.5) << f(2, 3); }
  • A1576
  • B15156
  • C7576
  • D1556
Correct answer: A

Explanation

f(3) matches f(int, int = 5) exactly and gives 15; f(2.5) matches f(double) and gives 7; f(2, 3) gives 6.

Discussion 0

Nobody has replied yet. Start the discussion!