Code a C++ program that will display the value of a given variable, and reference to another address, then, the value point-to another address. Given the value of variable is equal to 750.
#include <iostream>
using namespace std;
int main() {
int variable = 750;
int another = 0;
int *pointer = &variable;
cout << "Value of variable = " << variable << endl;
cout << "The value by pointer = " << *pointer << endl;
pointer--;
cout << "The value pointed-to another address = " << *pointer << endl;
return 0;
}
Comments
Leave a comment