Assistance with void function

# In the main
* create a double and assigns it a value
* create a pointer that points to the double
* use a cout statement to display text describing what you are displaying and then display each in turn:

1. the double address
2. the double value
3. the pointer address
4. the pointer value (pointers hold addresses, this should be the address of the double)
5. the deference pointer value (what the pointer is pointing to, the double value)

# Create a method that takes a pointer and a double (pass double by value) displays the values of the pointer and double as you did in the main
#
* changes the values of the double and then assign the point the value of the double (*pointer = double)
*
o if ptr is the point name and x is the name for the double then *ptr = x;
* The function should be void

# Back in the main re-display the addresses and values of the pointer and the double
# Remember to add your name and paste your output to the bottom of your file.


this is what I have so far, I think I have the but I need the void function corrected. Is it something like *** void display(double* ptr, double x)**?? I am lost.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
int main()
{
	double* p1;
	double* p2;
	double x = 99.9;
	double y = 101.1;
	double* temp;
	double* temp1;
	p1 = &x;
	p2 = &y;

	temp = p1;
	temp1 = p2;

	cout << "The original address of double x is: " << temp << endl;
	cout << "The original value of double x is: "<< x << endl;
	cout << "The original address of pointer ptr is: " << p1 << endl;
	cout << "The original value of pointer ptr is: " << &x << endl;
	cout << "The original dereferenced value of pointer ptr is: " << *p1 << endl;
	cout << "" << endl;

	cout << "The function address of double y is: " << temp1 << endl;
	cout << "The function value of double y is: " << y << endl;
	cout << "The function address of pointer pnt is: " << p2 << endl;
	cout << "The function value of pointer pnt is:" << &y << endl;
	cout << "The function dereferenced value of pointer pnt is: "<< *p2 << endl;
	cout << "" << endl;

	cout << "The new address of double x is: " << p2 << endl;
	cout << "The new value of double x is: " << y << endl;
	cout << "The new address of pointer ptr is: " << *p2 << endl;
	cout << "The new value of pointer ptr is: " << &y << endl;
	cout << "The new dereferenced value of pointer ptr is: " << y << endl;

	cout << " "<< endl;

	system("pause");
Last edited on
Is it something like *** void display(double* ptr, double x)**??
Yes, it is
Topic archived. No new replies allowed.