Form A Key: Q A Explanation 1. 3 (For answers to questions 1-5 see the course notes.) 2. 6 3. 5 4. 5 5. 4 6. 3 6.0 + 5 / 4 = 6.0 + 1 = 7.0 7. 4 9 % 10 + 3 = 9 + 3 = 12 8. 1 11 + 5.8 = 16.8 which is stored as 16 9. 2 Uppercase X instead of * for multiplication. 10. 1 OK, (double + integer) is an double. 11. 1 OK, sulu is coerced to an integer. 12. 2 Left hand side of '=' must be a variable. 13. 1 -1 > -2 is true. 14. 3 need 5 * y, 2 * z not 5y and 2z. 15. 2 evaluates to false OR false AND false which is false. 16. 1 evaluates to false OR true which is true. int uno = 1, dos = 2, tres = 3, quattro = 4; infile >> uno >> dos; //reads values 12, 13 infile.ignore(100, '\n'); //skips to beginning of line 2 infile >> tres >> quattro; //reads values 7, 20 infile.ignore(100, '\n'); //skips to beginning of line 3 infile >> dos >> tres >> tres; //reads values 9, 28, 41 infile.ignore(100, '\n'); //skips to beginning of line 4 17. 1 (For questions 17-20 see code comments above.) 18. 5 19. 4 20. 3 int i1 = 17; char ch1 = 'a', ch2 = 'b', ch3 = 'c'; iFile >> ch1; //reads '4' iFile >> i1; //reads 3 iFile.get(ch2); //reads '\t' 21. 1 (For questions 21-22 see code comments above.) 22. 6 23. 4 4, 1, 4, 9 are read on the first iteration 24. 3 The outer if statement is true, D becomes 3 the inner if statement is also true, D becomes 2 int anInt1, anInt2, anInt3; float aFloat1, aFloat2; fred >> anInt1 >> anInt2 >> aFloat1 >> anInt3; //reads 53, -21, 17.9, 19 cout << anInt1 << anInt2 << aFloat1 << anInt3; //writes 53, -21, 17.9, 19 fred.ignore(80, '\n'); //skips to beginning of line 2 fred >> anInt3 >> aFloat2; //reads 2, 0.4 fred.ignore( 6, '\n'); //skips 6 characters fred >> anInt2; //reads 12 cout << anInt3 << aFloat2 << anInt2; //writes 2, 0.4, 12 25. 2 (For questions 25-28 see code comments above.) 26. 6 27. 1 28. 7 29. 7 the else belongs to the inner if 30. 7 (K % 2 == 0) is true, alpha becomes 6 K becomes 7 (K % 2 == 0) is false, skips statement K becomes 8 (K % 2 == 0) is true, alpha becomes 14 31. 4 Goes to 1, then 3, then 5, setting passed to 10. 32. 1 there is no 4, so default is executed, passed is set to 0 33. 1 check for addition operation 34. 2 perform addition operation 35. 3 check for subtraction operation Form B Key: Q.No# Answer "Corresponding question in Form A" 1 1 17 2 5 18 3 4 19 4 3 20 5 1 8 6 3 24 7 3 6 8 4 7 9 4 23 10 1 21 11 6 22 12 2 25 13 6 26 14 1 27 15 7 28 16 4 31 17 1 32 18 7 30 19 7 29 20 1 13 21 3 14 22 2 15 23 1 16 24 2 9 25 1 10 26 1 11 27 2 12 28 1 33 29 2 34 30 3 35 31 4 5 32 3 1 33 6 2 34 5 3 35 5 4