Please send questions to
st10@humboldt.edu .
/*------------------------------------------------
signature: main: void -> int
purpose: to play with pointers
examples: when you run this program,
the following should be printed to the
screen:
num_ptr is: <an address>
*num_ptr is: 13.7
weight is: 13.7
num_ptr is: <same address>
*num_ptr is: 25.8
weight is: 25.8
num_ptr is: <same address>
*num_ptr is: 42
weight is: 42
by: Sharon Tuttle
last modified: 12-3-10
------------------------------------------------*/
#include <iostream>
using namespace std;
int main()
{
double *num_ptr;
double weight = 13.7;
num_ptr = &weight;
cout << "num_ptr is: " << num_ptr << endl;
cout << "*num_ptr is: " << *num_ptr << endl;
cout << "weight is: " << weight << endl;
cout << endl;
*num_ptr = 25.8;
cout << "num_ptr is: " << num_ptr << endl;
cout << "*num_ptr is: " << *num_ptr << endl;
cout << "weight is: " << weight << endl;
cout << endl;
weight = 42;
cout << "num_ptr is: " << num_ptr << endl;
cout << "*num_ptr is: " << *num_ptr << endl;
cout << "weight is: " << weight << endl;
return EXIT_SUCCESS;
}