Exam2_Review_Key.4

Exam2_Review_Key.4 - x == 14 and y == 7 before you call...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CPSC 121 Exam 2 Review Key d. declare a new name for an existing variable e. None of the above Short answer 19. What is wrong with this code fragment? The “catch all exceptions” catch has been placed before the “catch specific exceptions” catch. All exceptions will be caught by the … and none by the logic_error, which defeats the purpose of it being there. The logic_error catch should be placed first. try { //some code goes here } catch(…) { cerr << “Exception!\n”; keep_window_open(); return 1; } catch(const logic_error& e) { cerr << “Logic error: “ << e.what() << “\n”; keep_window_open(); return 2; } 20. Write a function (call it swapie( )) that takes two doubles as arguments and swaps their values; i.e., if
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x == 14 and y == 7 before you call swapie( ), then after you call swapie( ) x == 7 and y == 14. void swapie( double& a, double& b) { double temp; temp = a; a = b; b = temp; } 21. Given the partial code below, add lines of code to complete the square. Polygon p; //closed shape p.add(200, 200); p.add(200, 300); p.add(300, 300); p.add(300, 200); 22. It is sometimes said that a programmer is someone who cannot tell the difference between Halloween and Christmas, so what is the output of the following? cout << oct << 031 << \n; cout << dec << 25 << \n; 31 25...
View Full Document

This note was uploaded on 02/18/2012 for the course CSCE 121 taught by Professor Walter daugherity during the Fall '09 term at Texas A&M.

Ask a homework question - tutors are online