-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnov29.cpp
More file actions
72 lines (53 loc) · 1.02 KB
/
nov29.cpp
File metadata and controls
72 lines (53 loc) · 1.02 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
using namespace std;
int main()
{
int x;
x = 10;
int &r = x; // r is now a nickname for x
cout << '\n';
cout << "x = " << x << " and r = " << r << '\n';
cout << "Now we will set r = 20\n\n";
r = 20; // changing r will change x. They are
// now names for the same storage location
cout << "x = " << x << " and r = " << r << '\n';
}
/*
//pasing by value
#include <iostream>
using namespace std;
void Twice(int&, int&); // DECLARE before use
int main()
{
int x = 5, y = 8;
cout << "Initial values of variables:\n";
cout << "\tx = ";
cout << x;
cout << "\ty = ";
cout << y;
cout << '\n';
cout << "Calling the function Twice(x,y)\n";
Twice(x,y);
cout << "The new values of x and y are:\n";
cout << "\tx = " << x << "\ty = " << y << '\n';
cout << "Goodbye!\n";
}
void Twice(int& a, int& b)
{
a *= 2;
b *= 2;
}
#include <iostream>
using namespace std;
void changeNum(int& num);
int main()
{
int num = 0;
changeNum(num);
cout << num;
}
void changeNum(int& num)
{
num = 5;
}
*/