CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Reference vs Value Parameter

C++ code walkthrough · Question 1
mediumFunctions

Code

Read carefully. What does this print?
1#include <iostream>
2using namespace std;
3 
4void modify(int a, int &b) {
5 a = a + 10;
6 b = b + 10;
7}
8 
9int main() {
10 int x = 5, y = 5;
11 modify(x, y);
12 cout << x << " " << y << endl;
13 return 0;
14}

Your answer

Next