Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Pointer & Reference Type | PPL

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 issues 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)

Leave a Comment