Ch9

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

What will the following statement output? cout<<&num1;

The memory address of the variable called num1

The __ and __ operators can be used to increment or decrement a pointer variable

++,--

Look at the following statement: sum=*array++; This statement...

assigns the dereferenced pointer's value, then increments the pointer's address

With pointer variables, you can__ manipulate data stored in other variables

indirectly

When this is placed in front of a variable name, it returns the address of that variable

& ampersand

Which of the following statements is not valid C++ code?

All of these are invalid (int ptr=&num1; int ptr=int *num1; float num1=*ptr2; )

A pointer variable is designed to store

a memory address

The contents of pointer variables may be changed with mathematical statements that perform

addition and subtraction

Every byte in the computer's memory is assigned a unique

address

The __, also known as the address operator, returns the memory address of a variable

ampersand (&)

A pointer variable may be initialized with

any address in the computer's memory

These can be used as pointers

array names

The statement int *ptr= new int;

assigns an address to the variable named ptr

Which statement display the address of the variable num1?

cout<<&num1

Use the delete operator only on pointers that were

created with the new operator

What does the following statement do? double *num2;

declares a pointer variable named num2

Which of the following statements deletes memory that has been dynamically allocated for an array

delete[] array;

The following statement has the same meaning as __. int *ptr;

int* ptr;

Not all arithmetic operations may be performed on pointers. For example, you cannot __ or __ a pointer

multiply or divide

When you pass a pointer as an argument to a function, you must

none of these (redeclare the pointer pointer variable in the function call, dereference the pointer variable in the function prototype, use the #include<func_ptr.h> statement, not dereference the pointer in the function's body)

Look at the following statement. int *ptr; In this statement, what does the word int mean

ptr is a pointer variable that will store the address of an integer variable

A function may return a pointer, but the programmer must ensure that the pointer

still points to a valid object after the function ends

The statement cin>> *num3

stores the keyboard input into the variable pointed to by num3

When using the new operator with an older compiler, it is good practice to

test the pointer for the NULL address

When you work with a dereferenced pointer, you are actually working with:

the actual value of the variable whose address is stored in the pointer variable

A pointer may be initialized with

the address of an existing object

If a variable uses more that one byte of memory, for pointer purposes its address is

the address of the first byte of storage

When the less than (<) operator is used between two pointer variables, the expression is testing whether

the address of the first variable comes before the address of the second variable in the computer's memory

Assuming ptr is a pointer variable, what will the following statement output? cout<<*ptr

the value stored in the variable whose address is contained in ptr

Dynamic memory allocation occurs

when a new variable is created at runtime


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

Chapter 16: Law and Ethics in Abnormal Psychology

View Set

Religion LAUX ch1-4 (sections I & II)

View Set

terms you need to know (Shakespeare)

View Set

Mental Health Practice 2016 A (PERSONALIZED)

View Set

Lesson 7 - Business E-Mail and Personal Information Management

View Set

ATI Nursing Care of Children Practice A

View Set

Chemistry Chapter 3 and 4 EXAM STUDY GUIDE

View Set

Nursing Informatics (Midterm Scope)

View Set