Test 2 CSCI 130 Fall 2022

Name ______________________________________


  1. Input
    1. [6 points] Provide a general description of the operation of the following code: You should assume that SomeDataType is a legitimate data type.
      SomeDataType var;
      
      cin >> var; 
    2. [2 points] Specifically if SomeDataType is type string, what happens in the above code?
    3. [2 points] What does the function getline(stream, string) do?

  2. Comments
    1. [4 points] Name and describe the two types of comments available in c++
    2. [2 points] Given an example of each type of comment.
    3. [4 points] Other than comments, name two ways a programmer can write self documenting code.

  3. Strings and chars
    1. [2 points] What is the American Standard Code for Information Interchange (ASCII)?
    2. [2 points] Why is a char considered an integer type?
    3. [2 points] How is char treated differently than other integer types?
    4. [2 points] What is a string?

  4. Data Types
    1. [3 points] Name the three types of floating point type.
    2. [2 points] What does the reserved word unsigned do to an integer type?
    3. [3 points] What is the difference in these types?
    4. [4 points] What is numeric overflow and when does it occur? Given an example.

  5. Coding
    1. [10 points] Write a segment of code that asks a user for a first name, reads that in then asks for a last name and reads that in. Your program should allow for a single word first name, but a multi word last name. You should not process extra names supplied with the first name.