Podcast
Questions and Answers
What is the correct syntax to redirect the output from the program app into a file named output.txt?
What is the correct syntax to redirect the output from the program app into a file named output.txt?
- cat output.txt | app
- app > output.txt (correct)
- app | output.txt
- app < output.txt
Which command is used to display the contents of a file?
Which command is used to display the contents of a file?
- ls content.txt
- touch content.txt
- mkdir content.txt
- cat content.txt (correct)
What is the purpose of the touch
command?
What is the purpose of the touch
command?
- To delete a file
- To create a new file (correct)
- To rename a file
- To create a new directory
Which command is used to run unit tests?
Which command is used to run unit tests?
When should cin
be used?
When should cin
be used?
What is the purpose of cin.ignore()
?
What is the purpose of cin.ignore()
?
What operation is performed by the expression a / b
when a
and b
are integers?
What operation is performed by the expression a / b
when a
and b
are integers?
What is the purpose of mkdir
command?
What is the purpose of mkdir
command?
Study Notes
University of California, Merced - CSE 22: Introduction to Programming Midterm Examination
- The exam consists of 7 multiple-choice questions.
- The exam is a closed book exam, and no notes or electronic devices are allowed.
- The exam duration is 1 hour and 15 minutes.
- Students must write their first and last name and UC Merced email on the Scantron and Exam Booklet.
Redirecting Output
- The command
app > output.txt
redirects the output from the program app into a file named output.txt.
Printing File Contents
- The command
cat content.txt
prints the contents of the file content.txt to the console.
Creating a File
- The command
touch content.txt
creates the file content.txt.
Running Unit Tests
- The command
make test
runs the unit tests.
Input Streams
cin
should be used to ask the user to input a number or a single word string.cin
should not be used to ask the user to input a multi-word string.
Clearing Input Buffer
cin.ignore()
should be used to clear the input buffer when usingcin
aftergetline
.cin.ignore()
should not be used every timecin
is used or every timegetline
is used.
Integer Division
- The correct answer for the integer division question is not provided in the given text.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Introduction to Programming midterm exam for University of California, Merced, Spring 2024 semester.