Try this exercise. Click the correct answer from the options.
What will happen to the original values of variables account1
and account2
from the following code snippet?
TEXT/X-C++SRC
1#include <iostream>
2using namespace std;
3
4void transfer(int from_account, int to_account, double amount) {
5 from_account -= amount;
6 to_account += amount;
7}
8
9int main() {
10 int account1 = 5000;
11 int account2 = 2000;
12 transfer(account1, account2, 1000);
13 cout << "Account 1: " << account1 << endl;
14 cout << "Account 2: " << account2 << endl;
15}
Click the option that best answers the question.
- The values of `account1` and `account2` will decrease and increase respectively.
- The values of `account1` and `account2` remain unchanged.
- The values of `account1` and `account2` will both increase.
- The values of `account1` and `account2` will both decrease.