1int i creates a new integer in memory and labels it i If I


1.int i; creates a new integer in memory and labels it i. If I, instead, want a pointer to an integer, how would I modify int i?

   int *i;
   int #i;
   pointer i;
   int &i;


2.How would I declare a pointer called i that points to another pointer that points to an integer?

   int **i;
   const int *i;
   int *i = &i;
   int *i;


3.To make sure that the memory address my pointer points to cannot change, how would I modify int *i?

   int * const i;
   const int *i;
   int const i;
   const int i;


4.To make sure that the memory address my pointer points to and the value that is in that memory address cannot change, how would I modify int *i?

   int **i;
   const int * const i;
   const int *i;
   int * const i;


5.To make sure that the value that my pointer points to cannot be changed, how would I modify int *i?

   int * const i;
   const int i;
   const int *i = const;
   const int *i;


6.Given int *i = &some_val;

How would I change the value of some_val to 55 using the pointer i?

   i = &55;
   i = 55;
   *i = 55;
   &i = 55;


7.Given

int *i = &some_val;
int **j = &i;

How would I change some_val to 1234 using the pointer j?

   **j = 1234;
   *j = 1234;
   j = 1234;
   *j = &1234;


8.Given

int *i = &some_val;

How would I change the memory address that i points to another integer variable another_val?

   *i = &another_val;
   i = another_val;
   i = &another_val;
   *i = another_val;


9.Given

int a = 5512;
int *i = &a;
int **j = &i;
int ***k = &j;

What does the following code do?

**k = 0x1234;

   Sets a to 0x1234
   Sets i to point to 0x1234
   Sets k to point to 0x1234
   Sets j to point to 0x1234

10.Assuming that 0 is not a valid memory address and given,

int *i = 0;

What would occur if I did:

cout << *i << endl;

   Your program would grab the value in memory location 0.
   Your program would grab the address in memory location 0.
   cout would output 0
   Your program would crash for accessing an invalid memory address.

Solution

Hi, I have answered first 5.

Please repost others in separate post.

Please let me know in case of any doubt in first 5.


1.int i; creates a new integer in memory and labels it i. If I, instead, want a pointer to an integer, how would I modify int i?
int *i;
int #i;
pointer i;
int &i;

Ans; int *i; \'*\' operator is used to declare a pointer

2.How would I declare a pointer called i that points to another pointer that points to an integer?
int **i;
const int *i;
int *i = &i;
int *i;

Ans: int **i; since i points to a pointer, so it should be double pointer

3.To make sure that the memory address my pointer points to cannot change, how would I modify int *i?
int * const i;
const int *i;
int const i;
const int i;

Ans: const int *i; this is pointer to constant

4.To make sure that the memory address my pointer points to and the value that is in that memory address cannot change, how would I modify int *i?
int **i;
const int * const i;
const int *i;
int * const i;

Ans: const int * const i; This is constnt pointer to a constant variable

5.To make sure that the value that my pointer points to cannot be changed, how would I modify int *i?
int * const i;
const int i;
const int *i = const;
const int *i;

And: const int *i = const; this is a pointer to a constant

  

 1.int i; creates a new integer in memory and labels it i. If I, instead, want a pointer to an integer, how would I modify int i? int *i; int #i; pointer i; int
 1.int i; creates a new integer in memory and labels it i. If I, instead, want a pointer to an integer, how would I modify int i? int *i; int #i; pointer i; int
 1.int i; creates a new integer in memory and labels it i. If I, instead, want a pointer to an integer, how would I modify int i? int *i; int #i; pointer i; int

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site