Test 2 CSCI 130
Fall 2022
Name ______________________________________
- Please make sure that your name is on this page.
- Please staple this sheet to your answers, this page on top.
- Please answer each question fully, carefully and thoughtfully.
- No credit will be given for unreadable answers, please write neatly.
- Answer the questions in any order, but please number each answer.
- You may assume all code given is free from syntax errors. If you find a syntax error please ask.
- Input
- [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 points] Specifically if SomeDataType is type
string
, what happens in the above code?
- [2 points] What does the function
getline(stream, string)
do?
- Comments
- [4 points] Name and describe the two types of comments available in c++
- [2 points] Given an example of each type of comment.
- [4 points] Other than comments, name two ways a programmer can write self documenting code.
- Strings and chars
- [2 points] What is the American Standard Code for Information Interchange (ASCII)?
- [2 points] Why is a
char
considered an integer type?
- [2 points] How is
char
treated differently than other integer types?
- [2 points] What is a string?
- Data Types
- [3 points] Name the three types of floating point type.
- [2 points] What does the reserved word unsigned do to an integer type?
- [3 points] What is the difference in these types?
- [4 points] What is numeric overflow and when does it occur? Given an example.
- Coding
- [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.