Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

April 21, 2017 | Author: Randell Jefferson | Category: N/A
Share Embed Donate


Short Description

1 Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the pr...

Description

Name: ________________________ Class: ___________________ Date: __________

ID: A

Exam #1 - Prep True/False Indicate whether the statement is true or false. ____

1. Programming is the process of writing a computer program in a language that the computer can respond to and that other programmers can understand.

____

2. Computers are designed to respond to heuristic commands.

____

3. A data object consists of exactly one piece of data.

____

4. When all of the statements in a source program are translated before any one statement is executed, the programming language used is called a compiled language.

____

5. A keyword is a word that is set aside by the C++ language for a special purpose and should only be used in a specified manner.

____

6. A good function name should never be a mnemonic.

____

7. A C++ program does not always require a main() function.

____

8. The iostream file is referred to as a header file because a reference to it is always placed at the top, or head, of a C++ program using the #include command.

____

9. The compiler ignores all comments—they are there strictly for the convenience of anyone reading the program.

____ 10. Properly coded programs do not need comments if the program code is self-explanatory. ____ 11. To prevent the programmer from attempting to perform an inappropriate operation, C++ allows only certain operations to be performed on certain types of data. ____ 12. The term literal reflects the fact that such a value explicitly identifies itself. ____ 13. Limitations of small and extremely expensive memory are a major concern for the vast majority of programs. ____ 14. When the escape character is placed directly in front of a select group of characters, it tells the compiler to escape from the way these characters would normally be interpreted. ____ 15. Both the char and bool data types are signed data types. ____ 16. Floating-point numbers cannot be written in exponential notation. ____ 17. Character data cannot be displayed using cout.

2

Name: ________________________

ID: A

____ 18. The endl item is an example of an escape sequence. ____ 19. C++ does not allow mixed-mode expressions. ____ 20. Two binary arithmetic operator symbols may be placed side by side. ____ 21. Expressions containing more than one addition or subtraction are evaluated from left to right as each operator is encountered. ____ 22. An operator’s associativity establishes its priority in relation to all other operators. ____ 23. Assignment statements always have an equals (=) sign and one variable name immediately to the left of this sign. ____ 24. Variables that hold single-precision values are declared using the keyword float, whereas variables that hold double-precision values are declared using the keywords double float. ____ 25. Variables that have the same data type can always be grouped together and declared by using a single declaration statement. ____ 26. Declaring multiple variables in a single declaration statement requires giving the data type of variables only once, separating all variable names by commas, and using only one semicolon to terminate the declaration. ____ 27. Current C++ compilers can allocate sufficient storage for a variable without knowing the variable’s data type. ____ 28. The compiler only generates an error message for undeclared variables if they are not used in the program. ____ 29. An expression is any combination of constants, variables, and function calls that can be evaluated to yield a result. ____ 30. An example of coercion occurs when an integer value is assigned to a real variable. ____ 31. The statement sum = sum + 10; causes a new value to be stored in sum. ____ 32. The statement variable = variable + newValue; is an example of an accounting statement. ____ 33. The argument to the sqrt function must be a rational number. ____ 34. The expression sqrt(pow(abs(num1), num2)) is a valid expression. ____ 35. The C type cast syntax does not work in C++. ____ 36. Data for programs that are going to be executed only once should never be included directly in the program. ____ 37. A well-constructed program should validate user input and ensure that a program does not either crash or produce nonsensical output due to unexpected input.

2

Name: ________________________

ID: A

____ 38. C++ does not provide a way for programmers to assign symbolic names to constants, such as the mathematical constant PI. ____ 39. The expression (count + n)++ is a valid expression. ____ 40. Relational expressions cannot be used to compare operands. ____ 41. The logical operators AND, OR and NOT are used to create more complex relational expressions. ____ 42. Tests for equality of single-precision and double-precision values and variables using the relational operator == are usually reliable. ____ 43. The if-else statement directs the computer to select between two statements based on the result of a comparison. ____ 44. The use of braces to enclose a set of individual statements creates a single block of statements, which may be used anywhere in a C++ program in place of a single statement. ____ 45. The statement following if (expression) is executed only if the expression has a nonzero value (a true condition). ____ 46. if-else statements can not contain other if-else statements. ____ 47. An if-else chain is stopped once a true condition is found. ____ 48. An if-else chain can not be continued indefinitely by repeatedly making the last statement another if-else statement. ____ 49. In a switch statement, the keyword case is used to identify individual values that are compared to the value of the switch expression. ____ 50. Using the assignment operator, =, in place of the relational operator, ==, is a commonly made C++ programming error. Multiple Choice Identify the choice that best completes the statement or answers the question. ____

____

1. Another term for a computer program is ____. a. hardware c. b. software d.

object procedure

2. Programs written in low-level languages usually execute ____ than programs written in high-level languages. a. more accurately c. faster b. less accurately d. slower

3

Name: ________________________

ID: A

____

3. The purpose of a procedure is to accept ____ as input and transform it in some manner to produce a specific result as an output. a. numbers c. formulas b. objects d. data

____

4. An algorithm is a step-by-step sequence of ____ that describes how a computation is to be performed. a. data c. objects b. instructions d. classes

____

5. When English-like phrases are used to describe an algorithm (the processing steps), the description is called ____. a. a formula c. a program b. a flowchart d. pseudocode

____

6. The writing of an algorithm using computer-language statements is called ____ the algorithm. a. compiling c. interpreting b. coding d. debugging

____

7. The concept of creating a particular object from a larger defining set called a ____ is fundamental to all object-oriented programming languages, such as C++. a. super-set c. class b. master set d. relationship

____

8. To generate a program that can be executed by the computer requires that the C++ program, which is referred to as a source program, be translated into the computer’s ____. a. data c. objects b. machine language d. classes

____

9. You cannot write a C++ program without relying on some ____. a. high level code c. machine language b. procedural code d. pseudocode

____ 10. A(n) ____ program is simply a translated version of the source program that can be executed by the computer system with one more processing step. a. compiled c. object b. debugged d. C++ ____ 11. Most C++ programs contain statements that use ____ for input and output and for finding such quantities as square roots, absolute values, and other commonly encountered mathematical calculations. a. classes c. databases b. objects d. preprogrammed routines ____ 12. In C++, modules can be either ____ or functions. a. classes c. b. methods d.

objects procedures

____ 13. The first character of an identifier must be a ____ or an underscore (_). a. number c. letter b. mnemonic d. special character

4

Name: ________________________

ID: A

____ 14. We can tell the program which class or function to use by indicating the ____ where we want the compiler to look for the class or function. a. location c. module b. address d. namespace ____ 15. A programming language’s ____ is the set of rules for formulating statements that are grammatically correct for the language. a. syntax c. dictionary b. namespace d. format ____ 16. A data ____ is defined as a set of values and a set of operations that can be applied to these values. a. type c. base b. set d. dictionary ____ 17. A(n) ____ value consists of digits only and can optionally be preceded by a plus (+) or minus (-) sign. a. integer c. floating-point b. char d. signed ____ 18. The ANSI C++ standard requires that an int must provide ____ as much storage as a short int. a. at least c. three times b. twice d. four times ____ 19. The value of 1.625e3 is ____. a. .001625 b. 162.500

c. d.

1625 1625000

____ 20. The C++ statement ‘cout d.

,

____ 39. One of the most common C++ programming errors is forgetting to ____ values for all variables that are used in an expression. a. assign or initialize c. compute b. read in d. parameterize ____ 40. A computer’s ____ capability can be used to create an intelligence-like facility. a. adding c. subtracting b. comparison d. thinking ____ 41. A ____ relational expression consists of a relational operator connecting two variable and/or constant operands. a. standard c. single b. default d. simple ____ 42. Like all C++ expressions, relational expressions are evaluated to yield a ____ result. a. single-precision c. Boolean b. double-precision d. numerical ____ 43. ____ letters is essential in alphabetizing names. a. Comparing c. b. Capitalizing d.

Deleting Adding

____ 44. ____ can be used to alter the assigned operator priority and improve the readability of relational expressions. a. Colons c. Parentheses b. Semicolons d. Braces ____ 45. Many ____ numbers cannot be represented exactly in binary form using a finite number of bits. a. small c. integer b. large d. decimal ____ 46. For single-precision and double-precision operands, the general expression operand_1 == operand_2 should be replaced by this condition: a. operand_1 – operand_2 < EPSILON b. abs(operand_1 – operand_2) < EPSILON c. operand_2 – operand_1 < EPSILON d. operand_1 – operand_2 >= EPSILON ____ 47. Using ____ to enclose a set of statements creates a single block of statements. a. semicolons c. parentheses b. colons d. braces ____ 48. If age is initialized to equal 18, the statement age == 40 has a value of ____. a. 0 c. 18 b. 1 d. 30 ____ 49. ____ case labels may be contained within a switch statement. a. Up to 1 c. Up to 100 b. Up to 10 d. Any number of

7

Name: ________________________

ID: A

____ 50. It is ____ to terminate the last case in a switch statement with a break. a. required c. a syntax error b. mandatory d. not necessary

8

ID: A

Exam #1 - Prep Answer Section TRUE/FALSE 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40.

ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS:

T F F T T F F T T F T T F T F F F F F F T F T F T T F F T T T F F T F F T F F F

PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: 1

4 5 9 10 14 14 16 19 23 25 37 38 39 41 44 45 50 51 51 53 54 54 59 60 62 63 64 64 80 84 85 87 107 111 111 117 121 127 132 138

ID: A 41. 42. 43. 44. 45. 46. 47. 48. 49. 50.

ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS:

T F T T T F T F T T

PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS:

1 1 1 1 1 1 1 1 1 1

REF: REF: REF: REF: REF: REF: REF: REF: REF: REF:

139 142 143 146 149 158 159 160 168 173

PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF:

3 4 4 5 5-6 8 9 9 9 11 11 13 14 19 20 38 39 43 45 49 51 51 51 51 64 82 84 90 107 111 118 118

MULTIPLE CHOICE 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32.

ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS:

B C D B D B C B B C D A C D A A A A C B D D C C D A D B C A B A

2

ID: A 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50.

ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS: ANS:

C B B D C B A B D D A C D B D A D D

PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS: PTS:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF: REF:

3

121 127 127 128 132 132 132 137 138 138 139 141 142 142 146 151-152 168 171

View more...

Comments

Copyright � 2017 SILO Inc.