CSE 22 Midterm Exam Spring 2024
8 Questions
2 Views

CSE 22 Midterm Exam Spring 2024

Created by
@SofterBiedermeier

Podcast Beta

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</p> Signup and view all the answers

    When should cin be used?

    <p>A &amp; B</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></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</p> Signup and view all the answers

    What is the purpose of mkdir command?

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

    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

    Description

    Introduction to Programming midterm exam for University of California, Merced, Spring 2024 semester.

    More Like This

    Use Quizgecko on...
    Browser
    Browser