← 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;
}
- A.31 33 6
- B.31 23 6
- C.1 3 6
- 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 →