Last Name: First Name: Class Section: Matching Type the letter of the term which best matches the following descriptions (you may use the same answer more than once or not at all) :
13. What is the expected output for the following segment of code? int vals [4] = {3, 6, 9, 12}; printf ("%i", vals[1]); a. 3 b. 6 c. 9 d. 12 e. none of the above Answer: 14. The following for loop was started to print out the elements in the vals array (declared in #13). What should the loop condition be? int i; for (i=0; loop condition; ++i) body of loop a. i < 4; b. i <= 4; c. i < 5; d. i <= 5; e. none of the above Answer: 15. What should the body of loop be, from the code in #14? a. printf ("%i ", vals[1-4]); b. printf ("%i ", vals[0-3]); c. printf ("%i ", vals[1]); d. printf ("%i ", vals[i]); e. none of the above Answer: 16. What does the following code do: struct cat { char color [10]; int age; char gender; }; a. declare a variable called struct cat. b. define a data type called struct cat. c. declare 3 variables: color, age, and gender. d. declare 4 variables: cat, color, age, and gender. e. none of the above Answer: 17. Assume that values were assigned to the variable Tiger, declared below. What code will print out the age of Tiger: struct cat Tiger; a. printf("Tiger's age is %i ",age); b. printf("Tiger's age is %i ",Tiger); c. printf("Tiger's age is %i ",Tiger[age]); d. printf("Tiger's age is %i ",Tiger.age); e. none of the above Answer: 18. What is the output from the following code: int NUM = 10; int *x; x = &NUM; printf ("%i ", *x); a. x b. 10 c. &NUM d. *x e. none of the above Answer: 19. What is the result of the following code: char LETTER; char *P, *W; P = &LETTER; *P = 'J'; W = P; printf ("%c ", LETTER); a. P b. W c. J d. * e. none of the above Answer: 20. Using the same code given in #19, what would be the ouput from the following printf statement? printf ("%c ",*W); a. P b. W c. J d. * e. none of the above Answer: 21. What code will assign whatever the user types to the variable name: char name [10]; a. scanf ("%c", &name); b. scanf ("%s", &name); c. scanf ("%c", name); d. scanf ("%s", name); e. none of the above Answer: 22. What code will print out what was assigned to the variable name: a. printf ("%c", name[]); b. printf ("%s", name[]); c. printf ("%c", name); d. printf ("%s", name); e. none of the above Answer: