Name:     ID: 
 
Email: 

Chapter4 C++

True/False
Indicate whether the statement is true or false.
 

 1. 

A coded algorithm is called an object.
 

 2. 

Programmers typically desk-check a program using the same sample data used to desk-check the algorithm.
 

 3. 

The IPO chart shows the problem’s input, processing, and output items, as well as the algorithm needed to solve the problem.
 

 4. 

In most programming languages, the names of processing items can contain letters, numbers, underscores, punctuation characters or spaces.
 

 5. 

Most C++ programmers use uppercase letters for variable names.
 

 6. 

Items assigned the double data type typically are initialized to the value 1.0.
 

 7. 

All C++ statements must end with a colon.
 

 8. 

The standard output stream is called cout.
 

 9. 

The standard input stream is called stdin.
 

 10. 

The statement cout << "Enter current weekly pay: "; prompts the user to enter the current weekly pay.
 

 11. 

You should perform several desk-checks, using different data, to make sure that the program is correct.
 

 12. 

Errors in a program are called hacks.
 

 13. 

Machine code is usually called assembly code.
 

 14. 

You should assign a descriptive name to each variable and named constant used in a program.
 

 15. 

Punctuation characters are allowed in the name of a memory location.
 

 16. 

Names in C++ are case sensitive.
 

 17. 

To use the string class in a program, the program must contain the #include <string> directive.
 

 18. 

The binary number system uses only the two digits 0 and 1.
 

 19. 

Variables declared using the string data type usually are initialized to the empty string “”.
 

 20. 

A variable can be initialized to any value, as long as the value’s data type matches the variable’s data type.
 

 21. 

You can use an assignment statement to assign a value to a named constant.
 

 22. 

If an expression contains more than one operator having the same priority, those operators are evaluated from right to left.
 

 23. 

You can use the C++ ignore( ) function to instruct the computer to first read and then consume characters entered at the keyboard.
 

Multiple Choice
Identify the choice that best completes the statement or answers the question.
 

 24. 

____ is called the insertion operator.
a.
<-
c.
<<
b.
->
d.
>>
 

 25. 

____ is called the extraction operator.
a.
<-
c.
<<
b.
->
d.
>>
 

 26. 

____ refers to running the program, along with sample data, on the computer.
a.
Debugging
c.
Linking
b.
Testing
d.
Compiling
 

 27. 

____ refers to the process of locating and removing any errors in a program.
a.
Debugging
c.
Linking
b.
Testing
d.
Compiling
 

 28. 

You create a comment by typing ____ before the text you want treated as a comment.
a.
<<
c.
\\
b.
>>
d.
//
 

 29. 

____ is an example of a variable name using camel case.
a.
GrossPay
c.
gross_pay
b.
GROSSPAY
d.
grossPay
 

 30. 

The ____ data type stores a single precision floating-point number.
a.
short
c.
float
b.
double
d.
string
 

 31. 

The ____ data type stores zero or more characters.
a.
short
c.
char
b.
double
d.
string
 

 32. 

A program using the string class should contain the ____ statement.
a.
using <string>;
c.
using std::string;
b.
#include <std::string>
d.
#include <iostring>
 

 33. 

____ is a character literal constant.
a.
X
c.
‘x’
b.
“x”
d.
$x
 

 34. 

Memory locations having the bool data type typically are initialized using either the C++ keyword ____ or the C++ keyword ____.
a.
True, False
c.
TRUE, FALSE
b.
true, false
d.
T, F
 

 35. 

After executing the following lines of code, the result will be ____.

int average = 0;
double test1 = 90.0;
double test2 = 81.0;
average = (test1 + test2) / 2;
a.
85 assigned to average
c.
86 assigned to average
b.
85.5 assigned to average
d.
a syntax error
 

 36. 

The statement ____ creates a string variable named company and initializes it to the empty string.
a.
string company = '';
c.
string company = "";
b.
string company = ' ';
d.
string company = " ";
 

 37. 

The highest precedence number an arithmetic operator can have in C++ is ____.
a.
0
c.
100
b.
1
d.
1000
 

 38. 

The ____ function can be used to get string input from the user at the keyboard.
a.
getline( )
c.
getchars( )
b.
getstring( )
d.
gettext( )
 



 
         Start Over