1) (1 point) What are the five steps in the Problem Solving Methodology presented in the text for this course?
2) (1 points) What characters are used to identify the beginning and ending of comments in a C program?
/* <== beginning of comment and end of the comment ===> */
3) (2 points) This distance from the Earth to the Sun is approximately 93 million miles. Declare a variable of type double named "AstroUnit" and initialize it to this value using exponential notation.
double AstroUnit = 93.0e6; /* 9.3e7 is also perfectly acceptable, but perhaps not as readable */
4) (1 point) Variables that are not initialized are:
a) Initialized to zero automatically by the compiler.
b) Have no value at all.
c) Have what ever value corresponds to the pre-existing state of the corresponding memory locations. <=== Correct Answer
d) Are syntax errors and will be trapped by the compiler.
5) (1 point) The ASCII code associated with a lower case letter is always 32 greater than the code associated with an upper case letter. The ASCII code for the letter A is 65 (in decimal). The ASCII codes increase as the associated characters increase in alphabetical order - i.e., the ASCII code for Z is greater than the ASCII code for A. What value is stored in the following declaration?
int a = ('z' - 'A'); /* Notice: 'z' and not 'Z' */
answer = 57 since 'Z' = 'A' + 25, 'z' = 'Z' + 32 => 'z' - 'A' = ('Z' + 32) - 'A' = (('A' + 25) + 32) - 'A' = 25 + 32
6) (1 point) Write the definition statement for a symbolic constant for PI that satisfies the Style Guidelines for this course with respect to the use of parentheses in symbolic constant definition statements.
#define PI (3.1415926535897932)
Note: The value above has 17 sig figs so that it is compatible with the precision of type double on most compilers. The value you used is not a concern - using 3.14 or better is fine and 22/7 is acceptable (it's actually better than just 3.14) provided is it not done with integer arithmetic.
7) (1 point) What value is stored in the following statement?
k = 25 / 10 * 10;
k = 20 since (25 / 10) invokes integer division and is equal to 2 (2.5
truncated).