• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/10

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

10 Cards in this Set

  • Front
  • Back

Write A Statement that Displays the Address of the variable count.

cout << &count;

Write definition statement for variable fltPtr. A pointer to float

float *fltPtr;

List Three uses of *

Multiplication operator, pointer definition, indirection operator.

Output:


int x=50, y=60, z=70;


int *ptr = nullptr;




cout << x << " " << y << " " << z << endl;


ptr = &x




*ptr *= 10


ptr = &y


*ptr *= 5


ptr = &z;


*ptr *= 2;


cout << x << " " << y << " " << z << endl;

50 60 70


500 300 140

Rewrite w/ pointer:


for (int x=0; x<100; x++)


cout << arr[x] << endl;

for (int x=0; x<100; x++)


cout << *(array + x) << endl;

assume ptr is to int and &ptr= 12000. on a system with 4 byte integers, what address will be in ptr after...


ptr += 10;

12040

Assume pint is pointer variable. are these valid?




pint++;


--pint;


pint /= 2;


pint *=4;


pint += x; //assume x is int

valid


valid


invalid. only addition/subtraction for pointers


invalid.


valid

Valid or invalid?


_______


int ivar;


int *iptr= &ivar;


________


int ivar, *iptr = &ivar;


________


float fvar;


int *iptr= &fvar;


_______


int nums[50], *iptr = nums;


_______


int *iptr = &ivar;


int ivar;





valid


valid


invalid. fvar is a float and 1ptr is a pointer to int


valid


invalid. ivar must be declared before tptr.

9.9 Assuming arr is an array of ints, will each of the following program segments display “True” or “False”?


A) if (arr < &arr[1])


cout << "True";


else


cout << "False";


B)if (&arr[4] < &arr[1])


cout << "True";


else


cout << "False";


C)if (arr!= &arr[2])


cout << "True";


else


cout << "False";


D)if (arr!= &arr[0])


cout << "True";


else


cout << "False";

true


false


true


false

Give an example of the proper way to call the following function:


void makeNegative(int *val)


{


if (*val > 0)


*val = -(*val);



makeNegative (&num);