Chapter 7

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of element 3 of the array?

&t[ 3 ]

Three of the follow expressions have the same value. Which of the following expressions has a value different from the others'? *ptr &*ptr ptr *&ptr

*ptr

Which of the following can have a pointer as an operand?

++

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?

2012

To follow the principle of least privilege, the selectionSort function should receive the array to be sorted as:

A constant pointer to non constant data.

A function that prints a string by using pointer arithmetic such as ++ptr to output each character should have a parameter that is:

A non constant pointer to constant data.

A pointer can not be assigned to: Another pointer of the same type without using the cast operator. A pointer to void without using the cast operator. Any other pointer by using the case operator. A pointer of a type other than its own type and void without using the cast operator.

A pointer of a type other than its own type and void without using the cast operator.

Pointers may be assigned which of the following values? Any integer values. An address. Null Both (b) and (c).

Both (b) and (c).

A string array is commonly used for:

Command-line arguments.

All of the following can cause a fatal execution-time error except: Dereferencing a variable that is not a pointer. Dereferencing a variable that has not been assigned to point to a specific address. Dereferencing a pointer that has not been initialized properly. Dereferencing a null pointer.

Dereferencing a variable that is not a pointer.

( *max )( num1, num2, num3 ); :

Is a call to the function pointed to by max.

A string array:

Is actually an array of pointers.

void reverse( char *string1, const char *string2 ) { int stringsize = sizeof( string1 )/sizeof( char ) ; *( string1 + stringsize - 1 ) = '\0'; string1 = string1 + stringsize - 2; for ( ; *string2 != '\0'; string1--, string2++ ) *string1 = *string2; } What method does the function use to refer to array elements?

Pointer/offset notation

Pointers cannot be used to:

Reference values directly.

After the ith iteration of the selection sort:

The smallest i items of the array will be sorted into increasing order in the first i elements of the array.

Comparing pointers and performing pointer arithmetic on them is meaningless unless:

They point to elements of the same array.

cin.getline( superstring, 30 ); is equivalent to which of the following?

cin.getline( superstring, 30, '\n' );

When a compiler encounters a function parameter for a single-subscripted array of the form int a[ ] , it covers the parameter to

int *a

The & operator can be applied to:

lvalues.


Kaugnay na mga set ng pag-aaral

Chapter 14: Concepts of Acid-Base Balance

View Set

Chapter 17- Money Growth and Inflation

View Set

Eclampsia Practice Question (Test #4, Fall 2020)

View Set

CH 9: Nursing Theory: The basis of Professional Nursing

View Set