I have an assignment to "Create a C++ program that creates a decimal pointer, creates a variable set to a decimal value, then assigns the address of the variable to the pointer." I was kind of confused as to what I needed to do here, but this is what I came up with. The output I get from this code seems kind of awkward. I'm just hoping I'm understanding this problem correctly, and that what I created is sufficient. Any advice would be appreciated..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
double count = 5.1;
double *pCount = &count;
cout << "The Value of the count is " << count << endl;
cout << "The address of count is " << &count << endl;
cout << "The address of pCount is " << &pCount << endl;
Perhaps you did more than was asked for. If the instructions are followed meticulously , you end up with something like this:
1 2 3 4 5 6 7 8 9
// "Create a C++ program that
double *pCount; // creates a decimal pointer,
double count = 5.1; // creates a variable set to a decimal value,
pCount = &count; // then assigns the address of the variable to the pointer."
Of course there is no output. But unless there is more to the assignment than stated, no output is required.
I guess I was mostly confused as to why the program asks you to 'press any key to continue' twice..
Your program does that just once. However, if you are running the program from within an IDE (a combined editing/compiling/execution environment) then the IDE may itself be adding its own separate "Press any key to continue" after your program has ended.