PPL: Pointer & Reference Type

POINTER AND REFERENCE TYPE

Pointer: A pointer is a variable which is used to store the address of another variable.
It is used to allocate memory dynamically at run time.
The pointer variable might be int, float, char, double, short etc.

Pointer syntax:
int *a;

Some points to remember about pointer:
  • Pointer variable stores the address of the variable.
  • The content of the pointer always be a whole number i.e. address.
  • Pointer is initialized to null, i.e. int *a = null.
  • The value of null pointer is 0.
  • & symbol is used to get the address of the variable.
  • * symbol is used to get the value of the variable whose address pointer is holding.
  • Two pointers can be subtracted to know number of elements between these two pointers.
  • Pointer addition, multiplication, division are not allowed.

Pointer example:

int main()
{
   int *p, q;
   q = 10;
   p = &q;
   return *p;
}

What are the design isuues with pointer type?
The design issues for pointer types are 

  • what the scope and lifetime of a pointer variable are, 
  • what the lifetime of a heap-dynamic variable (the value a pointer references) is, 
  • if pointers are restricted as to the type of value to which they can point, 
  • if pointers are used for dynamic storage management, indirect addressing, or both, and 
  • if the language should support pointer types, reference type, or both.


MCQs on Pointer and Reference type

Q1. Pointer is special kind of variable which is used to store __________ of the variable.
a. Value    
b. Address    
c. Variable Name  

Q2. Pointer variable is declared using preceding _________ sign.
a. *
b. %
c. &

Q3. Address stored in the pointer variable is of type __________.
a. Integer
b. Character
c. Array

Q4. In order to fetch the address of the variable we write preceding _________ sign before variable name.
a. Comma
b. Ampersand
c. Asterisk

Q5. "&" is called as ___________ in pointer concept.
a. Address Operator
b. None of these
c. Conditional Operator

Q6. What do the following declaration signify? 
char *arr[4];
a. arr is a array of 4 character pointers.
b. arr is a array of function pointer.
c. arr is a array of characters.

MCQs Answers

Q1. (b)
Q2. (a)
Q3. (a)
Q4. (b)
Q5. (a)
Q6. (a)

Principles of Programming Languages

EasyExamNotes.com covered following topics in PPL.

Practicals:
Previous years solved papers:
A list of Video lectures
References:
  1. Sebesta,”Concept of programming Language”, Pearson Edu 
  2. Louden, “Programming Languages: Principles & Practices” , Cengage Learning 
  3. Tucker, “Programming Languages: Principles and paradigms “, Tata McGraw –Hill. 
  4. E Horowitz, "Programming Languages", 2nd Edition, Addison Wesley

Python Programming ↓ 👆
Java Programming ↓ 👆
JAVA EasyExamNotes.com covered following topics in these notes.
JAVA Programs
Principles of Programming Languages ↓ 👆
Principles of Programming Languages
EasyExamNotes.com covered following topics in these notes.

Practicals:
Previous years solved papers:
A list of Video lectures References:
  1. Sebesta,”Concept of programming Language”, Pearson Edu 
  2. Louden, “Programming Languages: Principles & Practices” , Cengage Learning 
  3. Tucker, “Programming Languages: Principles and paradigms “, Tata McGraw –Hill. 
  4. E Horowitz, "Programming Languages", 2nd Edition, Addison Wesley

    Computer Organization and Architecture ↓ 👆

    Computer Organization and Architecture 

    EasyExamNotes.com covered following topics in these notes.

    1. Structure of desktop computers
    2. Logic gates
    3. Register organization
    4. Bus structure
    5. Addressing modes
    6. Register transfer language
    7. Direct mapping numericals
    8. Register in Assembly Language Programming
    9. Arrays in Assembly Language Programming

    References:

    1. William stalling ,“Computer Architecture and Organization” PHI
    2. Morris Mano , “Computer System Organization ”PHI

    Computer Network ↓ 👆
    Computer Network

    EasyExamNotes.com covered following topics in these notes.
    1. Data Link Layer
    2. Framing
    3. Byte count framing method
    4. Flag bytes with byte stuffing framing method
    5. Flag bits with bit stuffing framing method
    6. Physical layer coding violations framing method
    7. Error control in data link layer
    8. Stop and Wait scheme
    9. Sliding Window Protocol
    10. One bit sliding window protocol
    11. A protocol Using Go-Back-N
    12. Selective repeat protocol
    13. Application layer
    References:
    1. Andrew S. Tanenbaum, David J. Wetherall, “Computer Networks” Pearson Education.
    2. Douglas E Comer, “Internetworking with TCP/IP Principles, Protocols, And Architecture",Pearson Education
    3. KavehPahlavan, Prashant Krishnamurthy, “Networking Fundamentals”, Wiley Publication.
    4. Ying-Dar Lin, Ren-Hung Hwang, Fred Baker, “Computer Networks: An Open Source Approach”, McGraw Hill.