C++ and Unix/Linux Basics Quiz
21 Questions
4 Views

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 purpose of the new keyword in C++?

  • To declare a pointer
  • To set a pointer to NULL
  • To delete a variable
  • To create a dynamic variable or object and return a pointer to it (correct)
  • A dangling pointer refers to a pointer that points to a memory location that has been deleted.

    True

    What is recursion?

    The process where a function calls itself to solve a problem.

    One byte is equivalent to ______ bits.

    <p>8</p> Signup and view all the answers

    Match the following data types with their respective sizes in bytes:

    <p>Int = 4 bytes Char = 1 byte Double = 8 bytes Float = 4 bytes</p> Signup and view all the answers

    Which command is used to change file permissions in Unix/Linux?

    <p>chmod</p> Signup and view all the answers

    The command 'mkdir' is used to delete files in Unix/Linux.

    <p>False</p> Signup and view all the answers

    What does 'cin.clear()' do in C++?

    <p>It clears the error state of the input stream.</p> Signup and view all the answers

    The command 'ls -l' provides detailed information about files, including their ______.

    <p>permissions</p> Signup and view all the answers

    Which of the following is a persistent I/O manipulator for cin/cout?

    <p>fixed</p> Signup and view all the answers

    Match the following commands with their functions:

    <p>ls = List directory contents cd = Change directory cp = Copy files or directories rm = Remove files or directories</p> Signup and view all the answers

    In C++, the type specifier '%d' is used for floating-point numbers.

    <p>False</p> Signup and view all the answers

    What does 'argv' stand for in the context of command-line arguments?

    <p>Argument vector</p> Signup and view all the answers

    What is always stored in the first element of argv?

    <p>The name of the program being executed</p> Signup and view all the answers

    String streams can only be used to write to files.

    <p>False</p> Signup and view all the answers

    What is the output of a binary search on a sorted array if the target is not found?

    <p>The output will typically be an index indicating 'not found' or a boolean false.</p> Signup and view all the answers

    The __________ sorting algorithm repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.

    <p>Bubble Sort</p> Signup and view all the answers

    Match the following number systems with their characteristics:

    <p>Decimal = Base 10 Binary = Base 2 Hexadecimal = Base 16 Octal = Base 8</p> Signup and view all the answers

    Which operator is a unary operator among the following?

    <p>~</p> Signup and view all the answers

    In C++, when an array is passed to a function, a copy of the entire array is made.

    <p>False</p> Signup and view all the answers

    What must be included to use string streams in C++?

    <p>#include <sstream></p> Signup and view all the answers

    Study Notes

    CS 102 Final Study Guide

    • This is a study guide for the final exam. It is not exhaustive and should be used in conjunction with other learning materials.

    • Midterm 1 Content (Including chmod):

      • VIM:
        • What is VIM?
        • Different modes
        • Opening files from the command line
        • Entering/exiting insert mode
        • Saving and exiting VIM
      • Unix/Linux:
        • Overview of Unix/Linux commands (e.g., ls, cd, mkdir, rm, cp, ssh, scp, chmod)
        • Explanation of each command
        • Permission string meanings (for commands like ls -l)
        • Using chmod to change permissions for files and directories
        • Understanding octal number systems with chmod.
      • Input/Output:
        • Number system used with chmod (octal)
        • C++ input/output syntax (cin/cout)
          • Including necessary headers
          • cin.clear() and its function
          • cin.ignore() and its function
          • Wrapping cin in statements
        • Printf
          • Type specifiers (%f, %d, etc.)
          • Precision control
          • Left/right justification
        • I/O manipulators
          • Including headers
          • Persistent/non-persistent manipulators (setw(), setfill(), left, right, setprecision, fixed, showpoint, scientific, hex, dec).
      • Vectors:
        • Definition of vectors
        • Comparison to Java vectors
        • Vector declaration syntax
        • Accessing and assigning vector elements
        • Vector functions(.push_back(), size(), clear(), resize().)

    Midterm 2 Content

    • Searching algorithms:
      • Linear search
      • Binary search
    • Sorting Algorithms:
      • Bubble sort
      • Selection sort
    • Insertion Sort:
      • Number systems (decimal, binary, hex)
      • Conversion between number systems
    • Binary Operations:
      • Binary operations (e.g., &, |, ^, <<, >>, ~)
      • Understanding unary operators
      • Understanding the differences between << and >>
    • Binary Application:
      • Using bitwise operations (set, clear, test bit)
      • Understanding the ASCII table (understanding that each character has a numeric value)

    Pass-by-Value. Pass-by-Reference

    • Pass-by-value and pass-by-reference differences in function syntax, parameter passing and reference variables
    • Function calls and copy creation
    • Array and other data type automatic passing in C++

    Pointers

    • Pointer declaration and setting
    • Pointer dereferencing
    • Dynamic variable creation
    • Memory management (deletion and NULL pointers)
    • Errors: seg fault, dangling pointer, memory leaks

    File Streams

    • File streams Overview
    • Writing and reading to/from files using ifstream and ofstream
    • Opening, closing, checking for errors
    • Insertion/extraction operators
    • Error checking

    String Streams

    • Similarities/differences to console/file streams
    • Using istringstream and ostringstream
    • Writing to and extracting from strings
    • Insertion/extraction operators.

    Recursion

    • Definition of recursion
    • Function definition recognition of recursion
    • Parts of a recursive subroutine

    Data Types

    • Data type sizes in bytes.
    • Number of bits in a byte
    • Data type values ranges

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    CS 102 Final Study Guide PDF

    Description

    Test your knowledge on C++ programming concepts and Unix/Linux commands with this comprehensive quiz. From pointers to file permissions, challenge yourself on various fundamental topics. Perfect for beginners looking to solidify their understanding of these essential programming tools.

    More Like This

    Use Quizgecko on...
    Browser
    Browser