CSE 22 Midterm Exam Spring 2024

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

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?

  • ls content.txt
  • touch content.txt
  • mkdir content.txt
  • cat content.txt (correct)

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?

<p>make test (B)</p> Signup and view all the answers

When should cin be used?

<p>A &amp; B (A)</p> Signup and view all the answers

What is the purpose of cin.ignore()?

<p>To clear the input buffer when using <code>cin</code> after <code>getline</code> (B)</p> Signup and view all the answers

What operation is performed by the expression a / b when a and b are integers?

<p>Integer division (D)</p> Signup and view all the answers

What is the purpose of mkdir command?

<p>To create a new directory (D)</p> Signup and view all the answers

Flashcards

Output redirection syntax

Directs the output from a program into a specified file instead of the terminal.

cat command

Displays the contents of a text file on the terminal.

touch command

Creates a new, empty file in the current directory.

make test command

Executes the unit tests defined in the project to check code correctness.

Signup and view all the flashcards

Purpose of cin.ignore()

To clear the input buffer when using cin after getline

Signup and view all the flashcards

Integer division (a / b)

Returns the integer quotient of the division, discarding any remainder.

Signup and view all the flashcards

mkdir command

Creates a new directory (folder).

Signup and view all the flashcards

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 &gt; 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 using cin after getline.
  • cin.ignore() should not be used every time cin is used or every time getline 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.

Quiz Team

Related Documents

cse-22-practice-midterm.pdf

More Like This

CSE-3104 Compiler Lab Quiz 01
16 questions
CSE 101 Exam 1 Sample Questions
21 questions
CSE 111: Intro to Computer Science
37 questions
Use Quizgecko on...
Browser
Browser