CIs 217

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

A variable must always be declared and initialized before a pointer can point to it.

False

The memory locations given to dynamic memory space are determined when the program is compiled.

False

A pointer provides an indirect means of accessing the value of a particular data item.

True

Both the address operator and the indirection operator are unary operators.

True

A location in memory (a) is reserved whenever a variable is declared. (b) is reserved when a variable is used in a program. (c) can hold several different values at the same time. (d) cannot be reused once it is assigned a value.

a

How would you assign the value of a variable referenced by the pointer "a" to a variable (a) name = *a; (b) name = &a; (c) a = *name ; (d) name = a ;

a

If array name arrayName is passed to a function, C automatically passes __________. (a) &arrayName[ 0 ] (b) arrayName[ 1 ] (c) arrayName[ 0 ] (d) *arrayName

a

What method should be used to pass an array to a function that does not modify the array and only looks at it using array subscript notation? (a) A constant pointer to constant data. (b) A constant pointer to nonconstant data. (c) A nonconstant pointer to constant data. (d) A nonconstant pointer to constant data.

a

Which statement is false? (a) The unary * operator is called the indirection operator or the dereferencing operator. (b) The operand of the unary * operator must be a pointer. (c) The unary * operator returns the value of its operand. (d) Placing a * operator before a pointer dereferences the pointer.

a, b author chose c

A pointer variable (a) contains the data stored at a location in memory. (b) contains the address of a memory location. (c) can be used in input statements, but cannot be used in output statements. (d) can be changed to different values in both input and output statements.

b

An expression such as sizeof( arrayName ) / sizeof( double ) might typically be used to determine (a) the size of an array (b) the number of elements in an array (c) the number of elements in half an array (d) the size of an element of an array

b

Assume that a and b are pointers Choose the sentence that best describes the effect of this statement: b = a; (a) The value of name is copied into b. (b) The memory address stored in a is copied into b . (c) The memory address stored in b is copied into a. (d) The pointer a is now pointing to a different variable.

b

The statement y = &yPtr; (a) assigns the address of the variable y to pointer variable yPtr. (b) assigns the address of the variable yPtr to pointer variable y. (c) is a compilation error. (d) is a logic error.

b

When calling a function with arguments that should be modified, the __________ of those arguments are passed. (a) memory (b) addresses (c) values (d) complements

b

Which statement is false? (a) The notations int *array and int array[] are interchangeable. (b) Function prototypes may not be placed inside functions. (c) Good advice: To encourage software reusability, when passing an array, also pass the size of the array. (d) Global variable violate the principle of least privilege.

b

Assuming that t is an array and tPtr is a pointer to that array, what expression refers to the address of element 3? (a) *( tPtr + 3 ) (b) tPtr[ 3 ] (c) &t[ 3 ] (d) *( t + 3 )

c

Given that k is an integer array starting at location 2000, kPtr is a pointer to k, and each integer is stored in 4 bytes of memory, what location does kPtr + 3 point to? (a) 2003 (b) 2006 (c) 2012 (d) 2024

c

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

c

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

c

When a compiler encounters a function parameter for a single-subscripted array of the form int a[], it converts the parameter to (a) int a (b) int &a (c) int * a (d) int * const a

c

Which of the following gives the number of elements in the array int r[ ]? (a) sizeof ( r ) (b) sizeof ( *r ) (c) sizeof ( r ) / sizeof ( int ) (d) sizeof ( *r ) / sizeof ( int )

c

If bPtr = b (the name of array b[]), then array element b[ 3 ] can alternatively be referenced with the pointer expression __________. (a) bPtr + 3 (b) b[ bPtr + 3 ] (c) *b [ bPtr + 3 ] (d) *( bPtr + 3)

d

The definition int *count; (a) is a syntax error because only pointers can be defined with * notation. (b) is a compile-time error. (c) is a logic error. (d) is a correct definition of integer pointer count.

d

When the __________ of a variable is passed to a function, the indirection operator (*) may be used in the function to modify the __________ at that location in the caller's memory. (a) address, address (b) value, address (c) value, value (d) address, value

d

sizeof (a) is a binary operator (b) returns the total number of elements in an array (c) usually returns a double (d) returns the total number of bytes in an array

d


Ensembles d'études connexes

3) Homonymous Hemianopia & Hemi-neglect

View Set

Quiz: Little Women: Chapters 14-30

View Set

UNIT 6 BASIC DIGITAL Electronics

View Set

CFP 501 - Financial Planning Process and Insurance

View Set