A C17 program contains the prototype and call below. The variable w is an int, and the call appears after the prototype is in scope. Assume area finishes by executing a return statement with a value.
double area(double width, int height); int w = 4; double r = area(w, 3);
Put the steps the program performs for this call in order, from the moment the call expression is reached until r receives its value.
1.
Control goes back to the caller, and the returned value initializes r.
2.
The return expression is evaluated and its value is converted to double, the declared return type.
3.
The arguments w and 3 are evaluated and converted to their corresponding parameter types, with no required order between the arguments' preparation.
4.
The statements of the function body run until a return statement is reached.
5.
The parameters width and height receive copies of the converted argument values.
Unlock full course notes by signing up
Convert arguments before calculating ticks
A C17 timer helper produces four ticks per complete second. Its definition appears before the caller:
Inside a valid caller, the program executes:
What value is stored in total? Answer in ticks as an exact integer, to zero decimal places.
Predict values after return-type conversion
The functions below are compiled as C17 on a system where unsigned char holds 8 bits (values 0 to 255).
Each call in the table is printed with printf("%d\n", ...) when the function returns an integer type, and with printf("%.1f\n", ...) when it returns double. Enter exactly what each call prints, as a whole number or a number with one decimal place.
Audit a set of function interfaces
A C17 program contains these prototypes, with matching implementations supplied elsewhere:
Each option is an independent proposed addition, placed in an appropriate scope. Select every addition permitted by strict C17 function declaration, call, and return rules.