Hmm...Can I replace *area= A * B with area = &(A * B)?
Code:void rectangleMath(double *area, double *perim, double A, double B) { *area = A * B; *perim = (A + B) * 2; }
Hmm...Can I replace *area= A * B with area = &(A * B)?
Code:void rectangleMath(double *area, double *perim, double A, double B) { *area = A * B; *perim = (A + B) * 2; }
No. & takes the address of something. A*B has no address.
If you could, it wouldn't be the same thing. *area = A*B changes the object that area points to. area = &(A*B), if it were legal, would set the value of the local pointer called area to the address of A*B. The first way modifies the object in the caller (which is, presumably, the desired behavior here). The second way would modify the pointer only, and the object in the caller would not change in value.