True/False

1. Every C++ program must have a function named main.

2. A syntax template is a generic example of the C++ construct being defined.

3. A C++ identifier cannot start with a digit.

4. The C++ compiler considers the identifier CanOfWorms to be the same as the identifier canofworms.

 

5. Some C++ reserved words can also be used as programmer-defined identifiers.

6. In C++, a block (compound statement) is not terminated by a semicolon.

7. A file is a named area in secondary storage that is used to hold a collection of data.

8. The statement

const int N = 25;

is an example of an assignment statement.

9. The null statement is an empty statement consisting only of a semicolon.

10. In a C++ floating point constant, a decimal point is not required if exponential (E) notation is used.

11. In C++, the modulus operator (%) requires integer operands.

12. The statement

myVar++;

causes 1 to be subtracted from myVar.

Multiple Choice

13. Which of the following statements about the C++ main function is false?

a. Every program must have a function named main.

b. Program execution begins with the first executable statement in the main function.

c. The main function must call (invoke) at least one other function.

d. The word int in the function heading means that the main function returns an integer value (to the operating system).

14. Given the following syntax templates:

which one of the following is a valid "Thing"?

a. #xy#

b. @#$

c. $@yyyy

d. y#z

e. #Y

15. In the following syntax templates, underlining indicates an optional part of the definition, instead of the shading used in the text.

 

 

Which one of the following is not a valid "Yoyo"?

a. 123ABC

b. 321BB1

c. 1A

d. 33C23

e. C

16. Which one of the following is not a valid identifier in C++?

a. Hi_There

b. top40

c. UpAnDdOwN

d. 3BlindMice

e. CAPS

17. Which one of the following is not a valid identifier in C++?

a. myName

b. little

c. X123Y

d. Go Home

e. IdEnTiFiEr

18. Which of the following is a C++ reserved word?

a. float

b. Float

c. FLOAT

d. a and b above

e. a, b, and c above

19. Which of the following is not an integral type in C++?

a. int

b. char

c. short

d. double

e. long

20. Which of the following is not a floating point type in C++?

a. long

b. float

c. double

d. long double

e. a and d above

21. Which of the following is a valid integer constant in C++?

a. 5,123

b. 5.2

c. 289

d. a and c above

e. none of the above

22. Which of the following is a valid floating point constant in C++?

a. 22.8

b. 5.8E24

c. 0.0

d. a and b above

e. a, b, and c above

23. Which of the following is a valid constant declaration?

a. const int THIS_YEAR = 1776;

b. const int = 1776;

c. const 1776;

d. const int 1776 = THIS_YEAR;

e. a and d above

24. Which assignment statement could be used to store the letter A into the char variable someChar?

a. someChar = "A";

b. someChar = A;

c. someChar = 'A';

d. a and b above

e. a, b, and c above

25. In C++, the value of the expression 24 / 5 is:

a. 4.0

b. 4.8

c. 4

d. 5

e. none of the above

26. In C++, the value of the expression 24.0 / 5.0 is:

a. 4.0

b. 4.8

c. 4

d. 5

e. none of the above

27. In C++, the value of the expression 16 % 5 is:

a. 1

b. 2

c. 3

d. 4

e. 5

28. If delta and gamma are int variables, where delta = 20 and gamma = 15, what value is stored into gamma by the following statement?

gamma = gamma * delta;

a. 0

b. 15

c. 20

d. 300

e. none—the statement is invalid

29. In C++, the phrase "standard output device" usually refers to:

a. the keyboard

b. a floppy disk drive

c. the display screen

d. a CD-ROM drive

e. none of the above

 

30. Which of the following statements prints HappyBirthday on one output line?

a. cout << "Happy" << endl;

cout << "Birthday" << endl;

b. cout << "Happy";

cout << "Birthday" << endl;

c. cout << "HappyBirthday" << endl;

d. b and c above

e. a, b, and c above

Fill-In

31. In a C++ function, the statements enclosed by a { } pair are known as the ____________________ of the function.

 

32. A programming language is said to be ____________________ if it considers uppercase letters to be different from lowercase letters.

33. A(n) ____________________ is a location in memory, referenced by an identifier, in which a data value that can be changed is stored.

34. In C++, subprograms are referred to as ____________________.

35. The set of rules that determines the meaning of instructions written in a programming language is called ____________________.

36. A(n) ____________________ is a name associated with a function or data object and used to refer to that function or data object.

37. A(n) ____________________ is a specific set of data values along with a set of operations on those values.

38. The first line of a C++ function is known as the function ____________________.

39. Any constant value written in a program is called a(n) ____________________ value.

40. A(n) ____________________ is a statement that stores the value of an expression into a variable.

41. A(n) ____________________ is a statement that associates an identifier with a data object, a function, or a data type so that the programmer can refer to that item by name.

42. A(n) ____________________ is a location in memory, referenced by an identifier, where a data value that cannot be changed is stored.

43. ____________________ is the formal rules governing how valid instructions are written in a programming language.

44. An operator that has only one operand is called a(n) ____________________ operator.

45. The integer value that the main function returns to the operating system is called the ____________________.

46. An operator that has two operands is called a(n) ____________________ operator.

47. During the compilation phase, a C++ source program is processed first by the ____________________ program and then by the compiler.

 

 

48. In C++ systems, files ending with the suffix .h are called ____________________ files.