Good Afternoon,
I'm a little difficulty with this little program. The error is argument of type int (*)[5] is not incompatible with parameter of type double. I'm getting this error on
swapFour(&a, &b);
Here is the whole program code
double a =102.39, b=201.59;
double c=30.99, d=48.99;
double e=55.21, f=95.35;
//call swapFour with pointer type paramters
cout<<"before calling swapFour(...), a is " << a << " and a is " <<a <<endl;
swapFour(&a, &b); //watch, we pass &x and &y to this function!!!!!!
cout<<"after calling swapOne(...), x is " << a << " and y is " <<b <<endl;
//call swapFive with reference type paramters
cout<<"before calling swapFive(...), c is " << c << " and d is " <<d <<endl;
swapFive(c, d); //watch, we pass c and d to this function!!!!!!
cout<<"after calling swapFive(...), c is " << c << " and d is " <<d <<endl;
//call swapSix with value type paramters
cout<<"before calling swapSix(...), e is " << e << " and f is " <<f <<endl;
swapSix(e, f);
cout<<"after calling swapSix(...), e is " << e << " and f is " <<f <<endl;
Functions
//swapFour takes two pointer type parameters
void swapFour(double * a, double * b)
{
//watch carefully how we do the swaping. Compare this with swapTwo
double tp;
tp = *a;
*a = *b;
*b = tp;
}
//swapFive takes two reference type parameters
void swapFive(double & a, double & b)
{
//watch carefully how we do the swaping. Compare this with swapOne
double tp;
tp = a;
a = b;
b = tp;
}
//swapSix takes two pointer type parameters
void swapSix(double a, double b)
{
//watch carefully how we do the swaping
double tp;
tp = a;
a = b;
b = tp;
}
I would really appreciated if anyone could help me fix this error.
Thank you