cse-22-practice-midterm.pdf

Full Transcript

UNIVERSITY OF CALIFORNIA, MERCED BERKELEY · DAVIS · IRVINE · LOS ANGELES · MERCED · RIVERSIDE · SAN DIEGO · SAN FRANCISCO SANTA BARBARA · SANTA CRUZ CSE 22: Introduction to Programming Midterm Examination...

UNIVERSITY OF CALIFORNIA, MERCED BERKELEY · DAVIS · IRVINE · LOS ANGELES · MERCED · RIVERSIDE · SAN DIEGO · SAN FRANCISCO SANTA BARBARA · SANTA CRUZ CSE 22: Introduction to Programming Midterm Examination Spring 2024 First Name Last Name UC Merced Email Instructions Write your first and last name as well as your official UC Merced on the Scantron and Exam Booklet. You must turn in both your Exam Booklet with your Scantron. This is a closed book exam. No notes and/or electronic devices may be used. Answer every question on the Scantron. You can use any blank part of the exam as scratch paper. You have 1 hours and 15 minutes to complete this exam. If you are unsure of anything, please ask. 1. Which command redirects the output from the program app into a file named output.txt? A. app > output.txt B. app < output.txt C. cat output.txt | app D. app | output.txt 2. Which command prints the contents of the file content.txt to the console? A. ls content.txt B. touch content.txt C. mkdir content.txt D. cat content.txt 3. Which command creates the file content.txt? A. ls content.txt B. touch content.txt C. mkdir content.txt D. cat content.txt 4. Which command runs the unit tests? A. make B. make run C. make test D. make unit tests 5. When should cin be used? A. To ask user to input a number. B. To ask user to input a single word string. C. To ask user to input a multi-word string. D. A & B E. B & C 6. When should cin.ignore() be used? A. Every time we use cin. B. Every time we use getline. C. To clear the input buffer when using cin after getline. D. To clear the input buffer when using getline after cin. E. C & D Page 2 7. Which of the following performs integer division? A. float x = 7 / 3; B. float x = 7.0 / 3; C. float x = 7.0 / 3.0; D. A & B E. None of the above 8. How many branches are guaranteed to be executed in the following code snippet? int x ; cin >> x ; if ( x >= 90) { cout x ; if ( x >= 60) { cout lastName >> age ; cin. ignore (); getline ( cin , city ); cout

Use Quizgecko on...
Browser
Browser