Class 12 Pointers in C++ Important Questions

Chapter 7 - Pointers in C++

This page contains important questions on Pointers in C++ for Class 12 Computer Science. The questions cover pointer declaration and initialization, dynamic memory allocation, new and delete operators, pointers and arrays, and pointers to structures, self-referential structures. These questions are useful for AHSEC/ASSEB Class 12 exam preparation

1. What is a pointer?

Answer :A pointer is a variable that stores the memory address of another variable.

2. Why do we need pointers?

Answer :Pointers are commonly used for:

  1. Accessing the address of a variable.
  2. Accessing a value indirectly.
  3. Working efficiently with arrays.
  4. Passing addresses to functions.

3. How do we declare a pointer?

Answer :A pointer is declared by placing an asterisk (*) before the pointer variable name.

Syntax for declaring a pointer variable is:

data_type *pointer_name

Examples

int *p;

 

float *q;

4. What is Address-of operator?

Answer :The & operator is called the address-of operator. It returns the memory address of a variable.

Syntax

&variable_name

Example

int x = 50;

cout << &x;

Here:

  • x  refers to the value stored in the variable
  • &x gives the memory address of the variable

5. What is dereferencing?

Answer :Dereferencing a pointer means accessing the value stored at the memory address held by the pointer.

6. What is null pointer?

Answer : A pointer that does not point to any valid memory location is called null pointer.

7. What is dynamic memory allocation?

Answer :Sometimes a program needs to allocate memory while it is running. This is called dynamic memory allocation. C++ provides the new operator for allocating memory dynamically and delete operator  to release dynamically allocated memory.

8.What is the use of new operator?

Answer :  The new operator is used to allocate memory dynamically.

Syntax

pointer = new data_type;

Example

int *p = new int;

This statement creates memory for an integer and stores its address in p.

9. What is the use of delete operator?

Answer : Memory allocated using new should be released when it is no longer required.The delete operator is used to release dynamically allocated memory

10. What is an array of pointers?

Answer : An array of pointers is an array in which every element is a pointer

11. What is the use of arrow operator?

Answer :The arrow operator (->) is used to access the members of a structure or class through a pointer

12.What is self-referential structure?

Answer :

A self-referential structure is a structure that contains a pointer to another structure of the same type.This concept is particularly important in linked lists and other dynamic data structures.

13. Which operator is used to obtain the address of a variable?

Answer: The address-of operator &.

14. Which operator is used to access the value pointed to by a pointer?

Answer : The dereference operator *

Scroll to Top