COSC 1436 STUDY GUIDE EXAM QUESTIONS AND
ANSWERS GRADED A+
✔✔The expression static_cast<int>(6.9) + static_cast<int>(7.9) evaluates to ____. -
✔✔13
✔✔The length of the string "computer science" is ____ - ✔✔16
✔✔In a C++ program, one and two are double variables and input values are 10.5 and
30.6. After the statement cin >> one >> two; executes, ____. - ✔✔one = 10.5, two =
30.6
✔✔Suppose that count is an int variable and count = 1. After the statement count++;
executes, the value of count is ____. - ✔✔2
✔✔Suppose that alpha and beta are int variables. The statement alpha = --beta; is
equivalent to the statement(s) ____. - ✔✔beta = beta - 1;
alpha = beta;
✔✔Suppose that alpha and beta are int variables. The statement alpha = beta++; is
equivalent to the statement(s) ____. - ✔✔alpha = beta;
beta = beta + 1;
✔✔Suppose that alpha and beta are int variables. The statement alpha = ++beta; is
equivalent to the statement(s) ____. - ✔✔beta = beta + 1;
alpha = beta;
✔✔Choose the output of the following C++ statement:
cout << "Sunny " << '\n' << "Day " << endl; - ✔✔Sunny
Day
✔✔Which of the following is the newline character? - ✔✔\n
✔✔Consider the following code.
// Insertion Point 1
using namespace std;
const float PI = 3.14;
int main()
{
//Insertion Point 2
, float r = 2.0;
float area;
area = PI * r * r;
cout << "Area = " << area <<endl;
return 0;
}
// Insertion Point 3
In this code, where does the include statement belong? - ✔✔insertion point 1
✔✔____ are executable statements that inform the user what to do. - ✔✔prompt lines
✔✔The declaration int a, b, c; is equivalent to which of the following? - ✔✔int a,b,c;
✔✔Suppose that alpha and beta are int variables and alpha = 5 and beta = 10. After the
statement alpha *= beta; executes, ____. - ✔✔alpha = 50
✔✔Suppose that sum and num are int variables and sum = 5 and num = 10. After the
statement sum += num executes, ____. - ✔✔sum = 15
✔✔When reading data into a char variable, after skipping any leading whitespace
characters, the extraction operator >> finds and stores only the next character; reading
stops after a single character. - ✔✔True
✔✔If input failure occurs in a C++ program, the program terminates immediately and
displays an error message. - ✔✔False
✔✔In an output statement, each occurrence of endl advances the cursor to the end of
the current line on an output device. - ✔✔False
✔✔You can use the function getline to read a string containing blanks. - ✔✔True
✔✔Suppose that x and y are int variables. Which of the following is a valid input
statement? - ✔✔cin >> x >> y;
✔✔Suppose that alpha is an int variable and ch is a char variable and the input is:
17 A
What are the values after the following statements execute?
cin >> alpha;
cin >> ch; - ✔✔alpha = 17, ch = 'A'
ANSWERS GRADED A+
✔✔The expression static_cast<int>(6.9) + static_cast<int>(7.9) evaluates to ____. -
✔✔13
✔✔The length of the string "computer science" is ____ - ✔✔16
✔✔In a C++ program, one and two are double variables and input values are 10.5 and
30.6. After the statement cin >> one >> two; executes, ____. - ✔✔one = 10.5, two =
30.6
✔✔Suppose that count is an int variable and count = 1. After the statement count++;
executes, the value of count is ____. - ✔✔2
✔✔Suppose that alpha and beta are int variables. The statement alpha = --beta; is
equivalent to the statement(s) ____. - ✔✔beta = beta - 1;
alpha = beta;
✔✔Suppose that alpha and beta are int variables. The statement alpha = beta++; is
equivalent to the statement(s) ____. - ✔✔alpha = beta;
beta = beta + 1;
✔✔Suppose that alpha and beta are int variables. The statement alpha = ++beta; is
equivalent to the statement(s) ____. - ✔✔beta = beta + 1;
alpha = beta;
✔✔Choose the output of the following C++ statement:
cout << "Sunny " << '\n' << "Day " << endl; - ✔✔Sunny
Day
✔✔Which of the following is the newline character? - ✔✔\n
✔✔Consider the following code.
// Insertion Point 1
using namespace std;
const float PI = 3.14;
int main()
{
//Insertion Point 2
, float r = 2.0;
float area;
area = PI * r * r;
cout << "Area = " << area <<endl;
return 0;
}
// Insertion Point 3
In this code, where does the include statement belong? - ✔✔insertion point 1
✔✔____ are executable statements that inform the user what to do. - ✔✔prompt lines
✔✔The declaration int a, b, c; is equivalent to which of the following? - ✔✔int a,b,c;
✔✔Suppose that alpha and beta are int variables and alpha = 5 and beta = 10. After the
statement alpha *= beta; executes, ____. - ✔✔alpha = 50
✔✔Suppose that sum and num are int variables and sum = 5 and num = 10. After the
statement sum += num executes, ____. - ✔✔sum = 15
✔✔When reading data into a char variable, after skipping any leading whitespace
characters, the extraction operator >> finds and stores only the next character; reading
stops after a single character. - ✔✔True
✔✔If input failure occurs in a C++ program, the program terminates immediately and
displays an error message. - ✔✔False
✔✔In an output statement, each occurrence of endl advances the cursor to the end of
the current line on an output device. - ✔✔False
✔✔You can use the function getline to read a string containing blanks. - ✔✔True
✔✔Suppose that x and y are int variables. Which of the following is a valid input
statement? - ✔✔cin >> x >> y;
✔✔Suppose that alpha is an int variable and ch is a char variable and the input is:
17 A
What are the values after the following statements execute?
cin >> alpha;
cin >> ch; - ✔✔alpha = 17, ch = 'A'