CSCI 240 - Set 1 Quiz Questions
1. (3) Most lines in a C++ program end with a
a. : (colon )
b. ; (semi-colon)
c. } (closing brace)
d. ) (closing parenthesis)
2. (3) main() marks the beginning of a C++
program. What C++ reserved word precedes it?
a. #include
b. using
c. void
d. a }
e. int
3. (3) What is the correct way to declare an integer variable named "score"?
a. int score
b. int score;
c. score: integer;
d. integer score;
e. none of the above
4. (3) Given the following declaration:
double x;
What is the value of x?
5. (2) According to the lecture notes, what are the two main conceptual components of a program?
6. (4) Given the following:
double price = 30.00; double tax = 1.80; double sum;
sum = price + tax;
Explain in detail what the last line does in terms of variables, calculations, and assignment of values.
7. (2) When you write an illegal C++ statement and try to compile and run the program,
you will get a
a. compile error
b. run-time error
c. logic error
d. machine crash
e. headache
8. (3) What is the value (in C++) of the expression 4 / 2 * 2?
9. (2) What is the value (in C++) of the expression 3/2?
10. (2) Which data type has the largest range?
a. int
b. float
c. double
d. it depends on the input value
11. (2) About how many decimal places of accuracy does a float have?
a. 31
b.12
c. 6
d. 4
12. (2) Modify (rewrite) the following instruction so that the subtraction is evaluated first:
i = a * b / c - d;