Example 1 — Integer arguments converted to double
The prototype makes 3 and 4 become 3.0 and 4.0.
#include <stdio.h>
double area(double w, double h);
int main(void) {
printf("area = %.2f\n", area(3, 4));
printf("area = %.2f\n", area(2.5, 4));
return 0;
}
double area(double w, double h) {
return w * h;
} How It Works
- With a prototype in scope,
intarguments are converted todouble. - Each call gets its own copies of
wandh. 2.5 * 4.0is 10.0.
