C primer final

¡Supera tus tareas y exámenes ahora con Quizwiz!

Consider the following code, assuming that x is an integer variable with an initial value of 12; if ( x = 6 ) printf ( "%i", x); What is the output? a) 6 b) 12 c) nothing d) a syntax error is produced

a) 6

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

a) Continue

What does the deck[52] array contain in the following statement? struct card, a deck[52], *cPtr; a) card structure elements b) a structure elements c) *cPtr elements d) none of these

a) card structure elements

____ repetition is sometimes called definite repetition. a) counter controlled b) sentinel controlled c) variable controlled d) none of these

a) counter-controlled

Which of the following is not a correct way to initialize an array? a) int n [5] = {0, 7, 0, 3, 8, 2}; b) int n [] = 0,7,0,3,8,2]; c) int n [5] = {7}; d) int n [5] = {6,6,6 };

a) int n [5] = {0, 7, 0, 3, 8, 2};

The function of the character-handling library is typically to manipulate characters as a a) integers b) floats c) longs d) bits

a) integers

In C it is appropriate to say that a string is a a) pointer b) integer c) double quote d) sequence of characters contained in a single quotes

a) pointer

A structure containing a member that is a pointer to the same structure type is referred to as a ____ structure. a) self referential b) self describing c) self aggrandizing d) self elemental

a) self-referential

Structure variables may not be initialized by a) setting user-defined default variables values in the struct definition b) assigning values to individual data members c) array like member initializer lists d) assignment statements

a) setting user-defined default variables values in the struct definition

+, \ and $ are all examples of a) special characters b) strings c) operators d) literals

a) special characters

Which statement is generally false? a) statements proceeding 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) initializations 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) statements proceeding a for and statements in the body of a for should typically be merged into the for header.

____ may contain different data types. a) structures b) arrays c) both a and b d) none of these

a) structures

Which one item is most different from the other three? a) worker function b) caller c) calling function d) boss function

a) worker function

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 mention it in the body of the loop.

b) The increment must be greater than zero

Structures may contain variables of many different data types -- in contrast to ____ that contain only elements of the same data type. a) files b) arrays c) constants d) functions

b) arrays

A non pointer variable name ____ references a value and a pointer variable name ___ references a value. a) directly, directly b) directly, indirectly c) indirectly, directly d) indirectly, indirectly

b) directly, indirectly

IN c the condition 4 > y > 1 a) evaluates correctly b) does not evaluate correctly and should be replaced by ( 4 > y && y > 1) c) does not evaluate correctly and should be replaced by ( 4 > y & y > 1) d) does not evaluate correctly and should be replaced by ( 4 > y || y > 1)

b) does not evaluate correctly and should be replaced by ( 4 > y && y > 1)

A character constant is a ___ value represented as a character in single quotes. a) short b) int c) long d) double

b) int

Functions are ____ by a function call. a) inveigled b) invoked c) internalized d) inverted

b) invoked

Which is not an ANSI standard library function a) printf b) main c) scanf d) pow

b) main

In a switch statement a) break is required after each case b) multiple actions do not need to be enclosed in braces c) a default case is required d) a break is required after the default case

b) multiple actions do not need to be enclosed in braces

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) print the numbers 1 through 10

Pointers cannot be used to a) find the address of a variable in memory b) reference values directly c) simulate call by reference d) manipulate dynamic data structures

b) reference values directly

____ repetition is sometimes called indefinite repetition. a) counter controlled b) sentinel controlled c) variable controlled d) none of these

b) sentinel-controlled

The OR (||) operator a) has higher precedence than the AND (&&) operator b) stops evaluation upon finding one condition to be true c) associates from right to left d) is a ternary operator

b) stops evaluation upon finding one condition to be true

Which of statement regarding the switch statement is false? a) it is appropriate for algorithms that contain a series of decisions in which a variable or expression is tested b) the default case is required c) the default case must be at the bottom of the switch after all the non defaults cases d) many cases may all invoke the same code

b) the default case is required

The for statement header for (i = 1; i < 100; i++) performs the body of the loop for a) value of the control variable from 1 to 100 in increments of 1 b) values of the control variable from 1 to 99 in increments of 1 c) values of the control variable from 0 to 100 in increments of 1 d) values of the control variables from 0 to 99 in increments of 1

b) values of the control variable from 1 to 99 in increments of 1

Three of the following expressions have the same value. Which of the followings value is different from the others? a) *&Ptr b) &*Ptr c) *Ptr d) Ptr

c) *Ptr

Which statement is false? a) structures are derived data types b) Each structure definition must end with a semicolon c) A structure can contain an instance of itself d) Structures man not be compared using operators == and ! =.

c) A structure can contain an instance of itself

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) Continue

Which statement is false? a) Each function should be limited to performin a single, well defined task b) If you cannot choose a concise name that expresses what a function does, it is possible that the function is attempting to perform too many diverse tasks. c) Every function should be broken into smaller functions. d) A functions parameters are local variables

c) Every function should be broken into smaller functions.

Which statement is true? a) Sentinel value are used to control repetition when precise number of repetitions is known in advance. b) Sentinel values are used to control repetition when the loop does not include statements that obtain data each time the loop is performed. c) sentinels must be distinct from data items. d) sentinel controlled repetition is often called definite repetition.

c) Sentinels must be distinct from regular data items.

Which of the following is not true? a) a string may include letters, digits, and various special characters (ie, +, -, *) b) A string in C is an array of characters ending in the null character ('\0'). c) String literals are written inside of single quotes d) A string may be assigned in a definition to either a character array or a variable of type of char

c) String literals are written inside of single quotes

___ are collections of related variables-sometimes referred as to aggregates - under one name. a) members b) enumerations c) structures d) files

c) Structures

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 12

c) an infinite loop

Which statement is false? a) any expression in c that produces a value can be used in the decision portion of any control structures b) when tested for truth of falsity, an expression that produces a non zero value is treated as true c) assignments in c produce a value namely the value that the left hand side of the assignment had prior to the assignment d) operator == is for comparisons operator = is for assignment

c) assignments in c produce a value namely the value that the left hand side of the assignment had prior to the assignment

Constant variables a) can be assigned values in executable statements b) do not have to be initialized when they are defined c) can be used to specify array sizes, thereby making programs more scalable d) can be used to specify array sizes, but this makes programs harder to understand

c) can be used to specify array sizes, thereby making programs more scalable

Experience has shown that the best way to construct a program is from small pieces. This is called___ a) bottom up b) the whole is greater than the sum of the parts c) divide and conquer d) recursion

c) divide and conquer

Lists, queues, stacks and trees are ___ data structures that may grow and shrink as programs execute. a) flexible b) automatic c) dynamic d) static

c) dynamic

Pointers are variables that contain ____ as their values a) strings b) flowlines c) memory addresses d) directions

c) memory address

'\n' represents the integer value of a) the character n b) the string n c) newline d) nextline

c) newline

Two structure variables with the same member values a) always compare equally b) never compare equally c) sometimes compare equally d) only compare equally if both structure variables contain holes

c) sometimes compare equally

If a do.... while statement is used a) an infinite loop will not take place b) the counter must be preincremented if it is also the condition c) the body of the loop will execute at least once d) an off by one error will not occur

c) the body of the loop will execute at least once

All of the following are true of functions except: a) they define specific tasks that can be used at many points in a program. b) a function call must specify the name and arguments of the function. c) the definition of a function is always visible to other functions d) the implementation of a function is hidden from the seller

c) the definition of a function is always visible to other functions

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) the initialization is performed each time through the loop

Which statement is true? a) the do... while repetition statement is an alternate notation for the while repetition statement; these statements function identically. b) the do... while repetition statements tests the loop continuation condition before the loop body is performed c) the loop body of a correct do.. while repetition statement is always executed at least once d) the braces delineating the body of a do... while statement area always required.

c) the loop body of a correct do.. while repetition statement is always executed at least once

Which statement is false? a) comma operators evaluate lists of expressions from right to left b) the value of a comma-separated list of expressions is the value of the rightmost expression in the list c) the type of a comma-separated list of expressions is the type of the rightmost expression in the list d) the comma operator is often used to specify multiple initializations in one particular type of repetition structure

c) the type of a comma-separated list of expressions is the type of the rightmost expression in the list

Arrays are data structures consisting of related items of the same a) sort order b) subscript c) type d) element

c) type

The & operator can be applied to a) constants b) variables defined with storage class register c) variables defined with storage class static d) rvalues

c) variables defined with storage class static

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) when a variable may assume many different values which must be tested against

The number 4 typically takes up to ____ bits when stored as a character on most of todays computers. a) 1 b) 2 c) 3 d) 8

d) 8

A programmer writes a for statement to count from 1 to 10 and explicity mentions the 1 and the 10 in the for "header" Which relational operator would probably be used in the loop continuation test? a) > b) >= c) < d) <=

d) <=

An operator that associates from right to left is a) != b) , c) () d) ?:

d) ?:

Which of the following is not a valid operation on a structure? a) assigning structure variables to structure variables of the same type b) taking the address of a structure variable c) using the sizeof operator to determine the size of a structure variable d) Comparing structures of the same type with the relational operators

d) Comparing structures of the same type with relational operators

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) EOF is a symbolic integer constant defined in the <stdio.h> header file

Which is not a motivation for "functionalizing" a program? a) The divide and conquer approach makes program development more manageable b) Software re-usability - using existing building blocks to create new programs c) avoid repeating code d) Execution performance - functionalized programs run faster.

d) Execution performance - functionalized programs run faster.

Which statement is false? a) counter controlled repetition is sometimes called definite repetition b) sentinel controlled repetition is sometimes called indefinite repetition c) the sentinel value typically indicates "end of data" d) in counter-controlled repetition, the control variable is always incremented by 1 each time the group instructions is performed.

d) In counter-controlled repetition, the control variable is always incremented by 1 each time the group instructions is performed.

Which statement is true? a) The boss function normally knows how the worker function performs its designated tasks. b) A worker function may not call the other worker functions. c) "Hiding" of implementation details makes it difficult to understand software. d) The boss function is normally unaware when a worker function calls a function.

d) The boss function is normally unaware when a worker function calls a function.

Which statement is true? a) The break statement causes an immediate exit from a while, for, do.... while or if .... else statement. b) The continue statement is designed for use with the while, for, do ... while or switch statements. c) an equivalent while statement for any for statement can always be formed. d) The break statement causes an immediate exit from a while, for, do.... while or switch statement.

d) The break statement causes an immediate exit from a while, for, do.... while or switch statement.

Which of the statements about pointers is false? a) They are among C's most difficult capabilities to master b) They enable programs to stimulate call by reference c) They are useful t create and manipulate dynamic data structures d) They cannot be used to create data structure that do not grow and shrink at execution time

d) They cannot be used to create data structure that do not grow and shrink at execution time

A valid reason for building programs out of functions is a) that the divide and conquer approach facilitates program construction b) that the pre existing functions can be used to create new programs c) the avoidance of code repetition within a program d) all of the above

d) all of the above

A string in C is a) an array of characters ending in the null string b) a sequence of characters contained within single quotes c) a sequence of characters preceded by a length field d) an array of characters ending in null character

d) an array of characters ending in null character

What happens if the loop continuation test is omitted in a for statement? a) c assumes the condition is false b) a syntax error occurs c) c assumes the condition is true, so the loop executes one more time then terminates d) an infinite loop

d) an infinite loop

Which of the following is not specified by the following correct code segment: for (c = 1; c< = 10; c++) a) initial value of the loop counter b) loop continuation test c) increment of the loop counter d) body statement of the loop

d) body statement of the loop

Pointers may be assigned to which of the following? a) all integer values b) an address c) null d) both (b) and (c)

d) both (b) and (c)

Which of the following is false? a) break and continue statements alter the flow of control. b) continue statements skip the remain in statements in the body of the loop in which they are embedded. c) break statements exit from the loop in which they are embedded. d) continue and break statements may be embedded within all C++ structures

d) continue and break statements may be embedded within all C++ structures

All of the following could cause a fatal execution time error except a) derereferencing a pointer that has not been assigned to point a specific address b) derefrencing a pointer that not been initialized properly c) dereferencing a 0 pointer d) derefrencing a non pointer

d) derefrencing a non pointer

The isxdigit (is hex digit) function would return false on a) a b) A c) 2 d) g

d) g

The expression if ( num ! = 65) can not be replaced by: a) if ( num > 65 || num < 65 ) b) if ! ( num == 65 ) c) if ( num - 65 ) d) if ! (num - 65)

d) if ! (num - 65)

Which definition tells the computer to reserve 12 elements for integer array c? a) c [12] int; b) int c [11]; c) [11] int; d) int c [12];

d) int c [12];

Which statement would be used to define a 10 element integer array c? a) array c = int [10]; b) c = int [10]; c) int array c [10]; d) int c[10];

d) int c[10];

When a called function completes its task, it normally a) terminates program execution normally b) aborts program execution c) logs its results d) returns to the calling function

d) returns to the calling function

Arrays and structures are ___ entities in that they remain the same size throughout program execution. a) dynamic b) automatic c) register d) static

d) static

Keyword ____ introduces the structure definition. a) structure b) str c) strdef d) struct

d) struct

Of the following which is not a logic error? a) using the assignment (=) operator instead of the (==) ) equality operator to determine if two values are equal b) dividing by zero c) failing to initialize counter and total variables before the body of a loop d) using commas instead of the two required semicolons in a for header

d) using commas instead of the two required semicolons in a for header


Conjuntos de estudio relacionados

CSCI 3301 Computer Organization - Hoque S16 - Test 1

View Set

Javascript Technical Interview (Theory)

View Set

Chapter 19: Infectious Diseases Affecting the Respiratory System

View Set

Fine Arts Survey A - Basic Techniques (Topic Test #2)

View Set

Micro ch 4-5 test (test questions)

View Set

Materials Chapter 13 Review Questions

View Set

HIST. 201 - Chapter 15: "What Is Freedom?": Reconstruction (1865 - 1877) Multiple Choice/Review Questions

View Set