🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: References and Functions: all 10 questions

Quiz: References and Functions · Question 6 of 10

What does this print? (code)

What does this print?

#include <iostream>
using namespace std;
void f(int a, int b = 10, int c = 20) { cout << a + b + c << " "; }
int main() {
    f(1);
    f(1, 2);
    f(1, 2, 3);
    cout << "\n";
    return 0;
}
  1. A.31 33 6
  2. B.31 23 6
  3. C.1 3 6
  4. D.31 23 26
Answer & explanation

Correct answer: 31 23 6

Missing arguments take their defaults: 1+10+20, 1+2+20, 1+2+3.

Can you get the rest right without peeking?

Take the timed Quiz: References and Functions quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →