Solution for Exercise 19-22
ex1922
#include <stdio.h>
void discount(float *a);
int main()
{
float price = 42.99;
printf("The item costs $%.2f\n",price);
discount(&price);
printf("With the discount, that's $%.2f\n",price);
return(0);
}
void discount(float *a)
{
*a *= 0.90;
}
Output
The item costs $42.99
With the discount, that's $38.69
Notes
* Line 17 may look odd because the * character is used as both the pointer and multiplication operators. Such things happen often in C.
Copyright © 1997-2025 by QPBC.
All rights reserved
