C++

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

3.7 Which of the following encompasses the other three? (a) sequence structure (b) repetition structure (c) control structure (d) selection structure

c

3.9 Which of the following is a repetition structure? (a) if (b) if...else (c) do...while (d) switch

c

4.14 Which of the following is not true? (a) the three expressions in the for statement are optional. (b) the initialization and increment expressions can be comma-seperated lists. (c) you must define the control variable outside of the for loop. (d) All of the above are true.

c

4.19. The comma operator is most often used in __________ statements. a) while b) do ... while c) for d) switch

c

4.2.Which statement is used to skip the remainder of the body of a repetition structure and proceed with the next iteration of the loop? a) skip b) proceed c) continue d) jump

c

4.22. Omitting the expression before the first required semi-colon in a for "header" is likely to cause a __________ error. a) syntax b) infinite loop c) logic d) divide-by-zero

c

4.28. Which statement about a correct for statement with an initialization expression, a loop-continuation test, an increment expression and a loop body is false? a) The incrementing is performed each time through the loop. b) The loop-continuation test is evaluated each time through the loop. c) The initialization is performed each time through the loop. d) The increment expression is performed after the loop body.

c

4.33. What is produced by a for statement with a correct body and with the following header for ( i = 20; i >= 2; i += 2 ) a) a syntax error b) a divide-by-zero error c) an infinite loop d) the even values of i from 20 down to 2.

c

4.38 A switch statement should be used (a) as a single-selection structure (b) as a double-selection structure (c) when a variable may assume many different values which must be tested against (d) to replace all if and if...else statements

c

The following line is most properly an example of a __________. printf("Welcome to C!"); a) function b) block c) statement d) header

c

Which is not a keyword? a) register b) volatile c) external d) struct

c

3.15. The __________ flowchart symbol is also called the action symbol. a) small circle b) diamond c) oval d) rectangle

d

3.21. The __________ selection statement performs one of many different actions, depending on the value of an expression. a) if b) when c) if ...else d) switch

d

3.43. Consider the following correct segment of a correct C program: p = 2; while ( p < 2000 ) p = 2 * p; What is the value of p after this while loop completes its execution? a) 1023 b) 1024 c) 2047 d) 2048

d

3.47 A fatal logic error is always caused by: (a) not initializing variables before executing a repetition structure (b) choosing a sentinel value that is also a data value (c) using a counter variable in a calculation after the loop (d) an attempt to divide by zero

d

3.53. Which statement is true? a) With nested control structures, the inner control structure is executed in sequence after the outer control structure completes its own execution. b) With nested control structures, the inner control structure is executed exactly once. c) Experience has shown that the most difficult part of solving a problem on a computer is converting an already correct algorithm to a C program. d) A double-selection structure can be nested in a repetition structure.

d

4.26 If the increment of the for statement is ________ then the loop counts ________. (a) true, downwards (b) false, downwards (c) positive, downwards (d) negative, downwards

d

4.35. Which expression raises x to the y power a) x ** y b) x ^ y c) x pow y d) pow( x, y )

d

4.41. Which statement is true? a) EOF must have the value 1 on all C systems. b) EOF is a symbolic constant defined in the <symbol.h> header file. c) EOF is a symbolic variable defined in the <stdio.h> header file. d) EOF is a symbolic integer constant defined in the <stdio.h> header file.

d

4.53. Which statement is true? a) Operator || has a higher precedence than operator &&. b) In expressions involving operator ||, making the condition that is most likely to be false the leftmost condition can often reduce execution time. c) The logical negation operator is a binary operator. d) In expressions using operator &&, making the condition that is most likely to be false the leftmost condition can often reduce execution time.

d

4.7 Which of the following does counter controlled repetition not require? (a) an initial value (b) a condition that tests for the final value (c) an increment or decrement by which the control variable is modified each time through the loop (d) counter controlled repetition requires all of the above

d

Another Simple Program: Adding Two Integers 2.15 Which of the following is not a valid integer value? (a) -3 (b) 0 (c) 2134859 (d) 1.1

d

The address operator is a) && b) % c) @ d) &

d

The order in which statements are __________ is called flow of control. a) entered in a source file b) preprocessed c) compiled d) executed

d

Which of the following is not a keyword? a) int b) return c) if d) main

d

Which of these is not a valid identifier? a) a_valid_identifier b) a1_valid_identifier c) a_valid_identifier_ d) 1_valid_identifier

d

3.55. Which assignment expression is equivalent to c = c / 2 ? a) c / = 2 b) c / c = 2 c) c /= 2 d) c =/ 2

c

3.19. The __________ selection statement performs an action if a condition is true and skips that action if the condition is false. a) if b) when c) if ...else d) switch

a

3.35 The conditional operator (?smile ________. (a) is the only ternary operator in C (b) is a unary operator (c) associates from left to right (d) accepts two operands

a

4.1. Which is not a repetition structure? a) continue b) for c) while d) do ... while

a

4.3 ________ repetition is sometimes called definite repetition. (a) counter-controlled (b) sentinel-controlled (c) variable-controlled (d) none of these

a

4.34. Which statement is generally false? a) Statements preceding a for and statements in the body of a for should typically be merged into the for header. b) Limit the size of control structure headers to a single line, if possible. c) Initialization of a for loop control variable can occur before the for loop executes and not in the loop itself. d) The increment portion of a for header can be a decrement.

a

4.54 Variables are also known as (a) lvalues, but can be used as rvalues (b) lvalues, and can not be used as rvalues (c) rvalues, but can be used as lvalues (d) constant variables

a

Evaluate the expression 3 * 4 % 6 + 4 *5 (a) 20 (b) 26 (c) 12 (d) 32

a

Variable names actually correspond to __________. (a) locations in the computer's memory (b) operators (c) integers (d) data types

a

Which of the following statements about the inclusion of is false? a) It is required. b) This header file contains information and declarations used by the compiler when compiling standard input/output library functions such as . c) This header file contains information that helps the compiler determine if calls to library functions have been made correctly. d) This header helps locate bugs in your program at compile time, rather than at execution time (when errors are usually more costly to correct).

a

Which statement is false. a) Variables may be defined anywhere in the body of main. b) All variables must be defined. c) All variable definitions must include the name and data type of each variable. d) Several variable of the same data type may be defined in one definition.

a

Which statement is false? a) The assignment operator associates from left to right. b) The arithmetic operators associate from left to right. c) The equality operators associate from left to right. d) The relational operators associate from left to right.

a

3.29. Indentation in the if selection statement is ________. (a) always mandatory (b) always optional (c) only mandatory if there is more than one statement following the if statement (d) only optional if there is more than one statement following the if statement

b

3.39. The empty statement is represented by placing __________ where a statement would normally be. a) empty b) ; c) null d) :

b

4.27. Which statement regarding for statements is false? a) In a for statement, the initialization, loop-continuation condition, and increment can contain arithmetic expressions. b) The increment must be greater than zero. c) If the loop-continuation condition is initially false, the body of the loop is not performed. d) It is common to use the control variable for controlling repetition while never mentioning it in the body of the loop.

b

4.32. What is the highest value assumed by the loop counter in a correct for statement with the following header? for ( i = 7; i <= 72; i += 7) a) 7 b) 77 c) 70 d) 72

b

4.43 The following program segment will int counter = 1; do { printf( "%i ", counter ); } while ( ++counter <= 10 ) ; (a) print the numbers 1 through 11 (b) print the numbers 1 through 10 (c) print the numbers 1 through 9 (d) cause a syntax error

b

4.9 Which of the following is a bad programming practice? (a) indenting the statements in the body of each control structure (b) using floating-point values as the counter in counter-controlled repetition (c) using more than two levels of nesting (d) placing vertical spacing above and below control structures

b

A __________ error is caused when the compiler can not recognize a statement. a) logic b) syntax c) linkage d) execution

b

The __________ sign is also known as the __________ operator. (a) +, assignment (b) =, assignment (c) *, stream manipulator (d) &, stream insertion

b

The escape sequence for horizontal tab is __________. a) \t ab b) \t c) \horizontaltab d) \T

b

Which of the following is false? a) Reading a value into a memory location destroys the previous value. b) Reading a value out of a memory location destroys that value. c) sum = integer1 + integer2; involves destructive read-in. d) The statement in part c) also involves nondestructive read-out.

b

Which operation will find the remainder when 15 is divided by 6? (a) 15 / 6 (b) 15 % 6 (c) 15 ^ 6 (d) 15 * 6

b

Which statement is false? a) The relational operators associate left to right. b) An execution time error will occur if the two symbols in any of the operators ==, !=, >= and <= are separated by spaces. c) Confusing the == operator with = operator is typically an error. d) The equality operators associate left to right.

b

3.1 Specifying the order in which statements are to be executed in a computer program is called (a) an algorithm (b) transfer of control (c) program control (d) pseudocode

c

3.23. The __________ is called a double selection structure. a) if b) when c) if ...else d) switch

c

3.27. Any C program we will ever need to build can be constructed from only __________ different types of control structures combined in only __________ ways. a) 7, 3 b) 6, 2 c) 7, 2 d) 6, 3

c

3.33. Which of the following statements correctly prints "Passed" if the student's grade is greater than or equal to 60 and "Failed" if the student's grade is less than 60? [The quotes, of course, should not print.] a) printf( "%s\n", grade >= 60 : "Passed" : "Failed" ); b) grade >= 60 : printf( "Passed\n" ) ? printf( "Failed\n" ); c) printf( "%s\n", grade >= 60 ? "Passed" : "Failed" ); d) grade >= 60 ? printf( "Passed\n" ) ? printf( "Failed\n" );

c

3.37 A statement is called a block ________. (a) if it is a compound statement (b) if it contains definitions (c) if it is a compound statement that contains definitions (d) if it does not contain definitions

c

3.41 What is wrong with the following while loop? While (sum <= 1000) sum = sum + 30; (a) The parenthesis should be braces. (b) Braces are required around sum = sum +30;. (c) While should be while. (d) There should be a semicolon after While ( sum <=1000 ).

c

3.5. Which statement is false? a) Pseudocode is an artificial and informal language that helps programmers develop algorithms. b) Pseudocode is similar to everyday English. c) Pseudocode is an actual programming language. d) Pseudocode programs are not actually executed on computers.

c

3.51. Which of the following is not a synonym for "sentinel value." a) signal value b) dummy value c) counter value d) flag value

c

Which of the following is false? a) Each variable being input in a scanf statement is generally preceded by an &. b) Each variable being output in a printf statement is generally not preceded by an &. c) In a printf statement, the comma that separates the format control string from the expressions to be printed is placed inside the format control string. d) Calculations can be performed inside printf statements.

c

Which statement is false? a) It is not correct to split an identifier with a space, a tab or a newline. b) Statements and comments may be split over several lines. c) The equals sign (=) is not an operator. d) A good programming practice is to break a line after a comma in a lengthy comma-separated list.

c


संबंधित स्टडी सेट्स

audit chapter 3, audit chapter 4, Audit CH 5

View Set

CIS 308 - Mobile and Wireless Technology

View Set

Role Transition modules 1-6 self check questions

View Set

Cyberattacks, Cybersecurity, Privacy, Freedom of Expression, Intellectual Property

View Set

CST Chapter 9 The principles and practice of aseptic technique

View Set

English File Upper Int 5B: Feeling Adjective Forms

View Set