Question
In C++ put together a program to discover the answers 1) For each of the following, write a single statement that performs the specified task.
In C++ put together a program to discover the answers
1) For each of the following, write a single statement that performs the specified task. Assume that int variables value1 and value2 have been declared, and that value1 has been initialized to 200000.
a) Declare the variable float_ptr to be a pointer to an object of type float.
b) Declare the variable int_ptr to be a pointer to an object of type int
c) Assign the address of variable value1 to pointer variable int_ptr.
d) Print the value of the object pointed to by int_ptr.
e) Assign the value of the object pointed to by int_ptr to the variable value2.
f) Print the value of value2.
g) Print the address of value1.
h) Print the address stored in int_ptr. Is the value printed the same as value1s address?
Problem #3, Chapter 7
Will the three memory locations displayed by the following program all be the same? Explain what is going on in the code.
#include
using namespace std;
int main()
{
int a = 10;
int& b = a;
int* c = &b;
cout << &a < cout <<&b < cout << &(*c) < return 0; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started