Question: Note: please write answer in the context of c++ language 1) Given an int x: Declare a pointer xptr to x. Use xptr to print

Note: please write answer in the context of c++ language

1)

Given an int x:

Declare a pointer xptr to x.

Use xptr to print out xs value.

Use xptr to assign a value of 7 to x.

Assign the address of xptr to a variable. What is its type?

2)What value should be assigned to a pointer that does not have a valid address?

3)

Given a string str:

Declare a pointer strptr to str.

Use strptr to print out strs value.

Use strptr to assign the value abc to str.

Use strptr to print out strs length.

4)

Given the following array and pointer declarations:

int arr[] { 1, 2, 3, 4, 5 };

int* arrptr = arr;

what is the output of each of the following statements? (assume they are not executed consecutively)

  1. cout << *arrptr;
  2. cout << *arrptr++;
  3. cout << *++arrptr;
  4. cout << ++*arrptr;
  5. cout << (*arrptr)++;

Write a statement that finds the number of elements in arr.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!