Mastering C++ Pointers

Mastering C++ Pointers

University

21 Qs

quiz-placeholder

Similar activities

Storage Classes and Memory Quiz

Storage Classes and Memory Quiz

University

20 Qs

oop with c++

oop with c++

University

20 Qs

Data Structure Quiz-1

Data Structure Quiz-1

University

20 Qs

Pointers

Pointers

University

20 Qs

PSC Quiz1

PSC Quiz1

University - Professional Development

20 Qs

Linux 3-4

Linux 3-4

University

20 Qs

CSI Coding Quiz

CSI Coding Quiz

University

20 Qs

revision

revision

University

17 Qs

Mastering C++ Pointers

Mastering C++ Pointers

Assessment

Quiz

Computers

University

Easy

Created by

Hai Nguyen

Used 1+ times

FREE Resource

21 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a pointer in C++?

A pointer is a special kind of loop in C++.

A pointer is a variable that stores a string in C++.

A pointer is a type of function in C++.

A pointer is a variable that holds the address of another variable in C++.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you declare a pointer variable?

int *ptr;

ptr: int;

pointer int ptr;

int ptr;

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is pointer arithmetic?

Pointer arithmetic is the process of converting pointers to integers.

Pointer arithmetic is the process of performing arithmetic operations on pointers to navigate through memory addresses.

Pointer arithmetic is the method of allocating memory for variables.

Pointer arithmetic refers to the use of pointers in function calls.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of dynamic memory allocation?

To create fixed-size arrays that cannot be resized.

The purpose of dynamic memory allocation is to allocate memory at runtime, allowing for flexible and efficient memory management.

To reduce the overall memory usage of a program.

To allocate memory only at compile time.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you allocate memory dynamically in C++?

Use 'calloc' for allocation and 'realloc' for deallocation.

Allocate memory using 'alloca' and 'dealloca'.

Use 'new' for allocation and 'delete' for deallocation.

Use 'malloc' for allocation and 'free' for deallocation.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you check if a pointer is null?

Check 'if (ptr != NULL)'

Use 'if (ptr = NULL)'

Use 'if (ptr == NULL)' or 'if (ptr == nullptr)'.

Use 'if (ptr != 0)'

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you deallocate memory in C++?

Use 'dispose' for both single objects and arrays.

Use 'free' to deallocate memory in C++.

Use 'malloc' to allocate memory only.

Use 'delete' for single objects and 'delete[]' for arrays.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?