Below is the correct modified code of your program. Compare this code with your previous code and try to point out your mistakes by yourself.
Code:
#include<iostream.h>
using namespace std;
void square(double *);
int main()
{
double x;
x = 123.456;
cout << "\n" << "In main(), before calling square(), x = " << x;
square(&x);
//Passing address of the variable x
cout << "\n" << " In main(), after calling square(), x = " << x;
system("pause");
}
void square(double *x) //read as: x is a pointer of type double
{
*x = *x * *x;
} //Notice that there is no space in *x