-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule4_ Lab4
More file actions
34 lines (27 loc) · 789 Bytes
/
Module4_ Lab4
File metadata and controls
34 lines (27 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Name: Kalani Codes <3
// Date: March 20th, 2025
// Purpose: Module 4 - Lab - Call By Reference
#include <iostream>
using namespace std;
void swapNumber(int &a, int &b) {
int temp = a;
a = b;
b = temp;
}
void addXtoY(int &x, int &y) {
x += y;
}
int main() {
int num1, num2, x, y;
cout << "Enter two integers to swap : ";
cin >> num1 >> num2;
cout << "Before swapping : " << num1 << " num2 = " << num2 << endl;
swapNumber(num1, num2);
cout << "After swapping : " << num1 << " num2 = " << num2 << endl;
cout << "Enter value for X and Y: ";
cin >> x >> y;
cout << "Before adding X to Y: x = " << x << ", y = " << y << endl;
addXtoY(x, y);
cout << "After adding X to Y: x = " << x << ", y = " << y << endl;
return 0;
}