← Quiz: References and Functions: all 10 questions
Quiz: References and Functions · Question 1 of 10
What does this print? (code)
What does this print?
#include <iostream>
using namespace std;
void f(int &x) { x = x * 2; }
int main() {
int a = 7;
f(a);
cout << a;
return 0;
}
- A.7
- B.14
- C.0
- D.Error
Answer & explanation
Correct answer: 14
x is a reference to a, so a becomes 14.
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 →