Chapter 22.5, 2.6, 2.7 Answers
2.5-P1 q = (k * a * (t1 - t2)) / l
2.5-P2 The statements that handle the declaration and input of your data in your program would look like this:
printf(Enter two characters followed by a number: );
scanf(%c%c%f, &char1, &char2, &number1);
2.6-2 %8.4f -> -15.5640%8.3f -> X-15.564 (using X to represent a blank)%8.2f -> XX-15.56%8.1f -> XXX-15.6 (note the decimal rounding)%8.0f -> XXXXX-16 (note the rounding)%.2f -> -15.56 (two decimals; no blanks in output)
2.6-P1 printf(%5d%11.2f%9.1f, a, b, c);
2.7-2 Interactive input comes from a human being via an input device such as a keyboard. The program issues prompts to the user, so the user knows what data is expected.
Batch data comes from a file, either opened by the operating system and substituted for the keyboard (redirection), or opened by the program itself (program-controlled). The file contains the data in the same order as it would have been typed in by the user.
Just as the same number typed in at the keyboard might be stored in an integer, a float, or a double, the numbers in a batch data file might be read by the program and stored in different ways. There is nothing about the content of the batch input file itself that says how the program will interpret the numbers. Different programs may read the same batch input file and read and store the numbers differently.