0% found this document useful (0 votes)
574 views3 pages

Pointer Questions Answers

Uploaded by

sbijjal2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
574 views3 pages

Pointer Questions Answers

Uploaded by

sbijjal2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1 MARK IMPORTANT QUESTIONS

1. Define pointer.

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

2. Write the declaration syntax for a pointer.

datatype *pointer_name;

Example: int *ptr;

3. How do we initialize a pointer?

A pointer is initialized by assigning it the address of a variable using the address operator (&).

Example: int x = 10; int *ptr = &x;

4. Write any one advantage of pointers.

Pointers enable dynamic memory allocation and efficient manipulation of arrays and data

structures.

5. What is the purpose of the new operator in C++?

The new operator is used to allocate memory dynamically at runtime.

6. What is a pointer variable?

A pointer variable is a variable that holds the memory address of another variable.

7. Which is the address operator?

The address operator is &, used to obtain the memory address of a variable.
8. What is the pointer operator?

The pointer operator (*) is used to access the value stored at the memory address held by a

pointer.

9. What is static memory & dynamic memory?

- Static memory: Memory allocated at compile time, such as global and local variables.

- Dynamic memory: Memory allocated at runtime using operators like new and delete.

10. What is free store?

The free store is a region of memory used for dynamic memory allocation, managed using new

and delete in C++.

3 MARK IMPORTANT QUESTIONS

1. What are the advantages of pointers?

- Allow dynamic memory allocation.

- Enable the creation of complex data structures like linked lists, trees, and graphs.

- Facilitate efficient array and string manipulation.

- Enable passing variables by reference to functions.

2. What are the operations performed on pointers?

- Initialization: Assigning a memory address to a pointer.

- Dereferencing: Accessing the value stored at the address.

- Arithmetic: Incrementing (++), decrementing (--), addition, and subtraction of pointers.

- Comparison: Comparing two pointers for equality or inequality.


3. What is an array of pointers? Give an example.

An array of pointers is a collection of pointers, where each element stores the address of another

variable.

Example:

int a = 10, b = 20, c = 30;

int *arr[3] = {&a, &b, &c};

4. Explain the new and delete operator in pointers.

- new: Allocates memory dynamically at runtime.

Example: int *ptr = new int;

- delete: Deallocates the memory previously allocated by new.

Example: delete ptr;

5. Define:

a. Pointer: A variable that holds the memory address of another variable.

b. Static memory allocation: Memory allocation done at compile time, fixed and cannot be resized

during execution.

c. Dynamic memory allocation: Memory allocation done at runtime, allowing flexible memory

usage with new and delete operators.

You might also like