Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main() {
- int i1 = 5;
- int i2 = 500;
- double d1 = 1.234;
- double d2 = 100.456;
- cout << "First integer = " << i1 << endl;
- cout << "First double = " << d1 << endl;
- int *iPtr = &i1;
- double *dPtr = &d1;
- cout << "address of first pointer = " << iPtr << " and address of second pointer = " << dPtr << endl;
- int i1DReferenced = *iPtr;
- double d1DReferenced = *dPtr;
- cout << "Dereferenced pointer of i1: " << i1DReferenced << " and dereferenced pointer of d1: " << d1DReferenced << endl;
- double d3 = *dPtr;
- *dPtr = 17.7;
- int i3 = *iPtr;
- *iPtr = 3;
- cout << "Changed value of i1 by dereferencing: " << i1 << endl;
- cout << "Changed value of d1 by dereferencing: " << d1 << endl;
- cout << "i1 Directly: " << i3 << endl;
- cout << "d1 Directly: " << d3 << endl << endl;;
- cout << "i2 directly: " << i2 << endl;
- cout << "d2 directly: " << d2 << endl;
- iPtr = &i2;
- dPtr = &d2;
- cout << "Address of i2: " << iPtr << endl;
- cout << "Address of d2: " << dPtr << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement