Jumaat, 23 Mac 2012

POINTER PART I

Dear students;
Answer all the questions, and submit to my email aminahpolimas@yahoo.com, by 25 March 2012. Kindly discuss in group/partner. Good luck!!

1.        How do you access the memory address of a variable?

2.        How do you access the contents of the memory location whose address is stored in a pointer  variable?

3.       Explain the difference between the following two declarations:

i.           int  n1=n;

ii.                         int& n2=n;

4.        Explain the difference between the following two uses of the reference operator &:

i.           int& r = n;

ii.                P = &n;

5.       Explain the difference between the following two uses of theindirection operator  *:

     i.      int* q = p;

     ii.     n  =  *p;

6.        True or false? Explain:
     i.          if (x == y) then (&x == &y)

    ii.          if (x == y) then (x* == *y)

7.        What is wrong with the following code:

                     int& r = 22;

8.        What is wrong with the following code:

                     int* p = &44;

9.        What is wrong with the following code:

                     char c = ‘w’ ;

                     char* p = c;

Tiada ulasan:

Catat Ulasan