-
Notifications
You must be signed in to change notification settings - Fork 0
/
referencing.cpp
50 lines (42 loc) · 941 Bytes
/
referencing.cpp
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
#include <iostream>
using namespace std;
// Functions prototype
int getValues(int*, int*, int*);
int doubleValues(int*, int*, int*);
int DisplayValues(int*, int*, int*);
int main()
{
int var1, var2, var3;
// Call the functions and passes the address of the variables
getValues(&var1, &var2, &var3);
doubleValues(&var1, &var2, &var3);
DisplayValues(&var1, &var2, &var3);
}
int getValues(int *var1, int *var2, int *var3)
{
//Gets integers
cout << "Enter an integer: ";
cin >> *var1;
cout << "Enter an integer: ";
cin >> *var2;
cout << "Enter an integer: ";
cin >> *var3;
return 0;
}
int doubleValues(int *var1, int *var2, int *var3)
{
// Double the integers value
*var1 *= 2 ;
*var2 *= 2 ;
*var3 *= 2;
return 0;
}
int DisplayValues(int *var1, int *var2, int *var3)
{
// Display the doubled values
cout << "\nThe values doubled are: \n"
<< *var1 << " "
<< *var2 << " "
<< *var3 << " " << endl;
return 0;
}