CSCI 240 - Exam 1 Review Questions with
Verified Correct Answers
Most lines in a C++ program end with a
semi-colon
main() marks the beginning of a C++ program. What C++ reserved word precedes it?
int
What is the correct way to declare an integer variable named "score"?
int score;
Given the following declaration: double x;
What is the value of x?
Garbage. It has no value
According to the lecture notes, the two main conceptual components of a program are
data and instruction
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
, The last line takes the price and tax, adds them together, and assigns that value to the sum
variable
When you write an illegal C++ statement and try to compile and run the program, you
will get a
compile error
What is the value (in C++) of the expression * 2?
4
What is the value (in C++) of the expression 3/2?
1
Which data type has the largest range?
double
About how many decimal places of accuracy does a float have?
6
Modify (rewrite) the following instruction so that the subtraction is evaluated first:
i = a * b / c - d;
i = a * b / (c - d);
What instruction will display data on the screen from a C++ program?
cout
About how many decimal places of accuracy does a float have?
6
Verified Correct Answers
Most lines in a C++ program end with a
semi-colon
main() marks the beginning of a C++ program. What C++ reserved word precedes it?
int
What is the correct way to declare an integer variable named "score"?
int score;
Given the following declaration: double x;
What is the value of x?
Garbage. It has no value
According to the lecture notes, the two main conceptual components of a program are
data and instruction
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
, The last line takes the price and tax, adds them together, and assigns that value to the sum
variable
When you write an illegal C++ statement and try to compile and run the program, you
will get a
compile error
What is the value (in C++) of the expression * 2?
4
What is the value (in C++) of the expression 3/2?
1
Which data type has the largest range?
double
About how many decimal places of accuracy does a float have?
6
Modify (rewrite) the following instruction so that the subtraction is evaluated first:
i = a * b / c - d;
i = a * b / (c - d);
What instruction will display data on the screen from a C++ program?
cout
About how many decimal places of accuracy does a float have?
6