C++ Pointers and Memory Management Quiz

C++ Pointers and Memory Management Quiz

University

5 Qs

quiz-placeholder

Similar activities

PBO - 1

PBO - 1

University

5 Qs

SWE111_quiz 2

SWE111_quiz 2

University

10 Qs

ITS Python 變數與運算式課堂測驗

ITS Python 變數與運算式課堂測驗

6th Grade - University

10 Qs

Abstracciones procedimentales

Abstracciones procedimentales

University

10 Qs

Dasar Koding dan Kecerdasan Buatan

Dasar Koding dan Kecerdasan Buatan

10th Grade - University

10 Qs

SQL Database Quiz

SQL Database Quiz

University

5 Qs

chapter 4- array

chapter 4- array

University

5 Qs

C++ Templates Quiz

C++ Templates Quiz

University

10 Qs

C++ Pointers and Memory Management Quiz

C++ Pointers and Memory Management Quiz

Assessment

Quiz

Information Technology (IT)

University

Hard

Created by

MAHANI BINTI ZAKARIA (POLIMAS)

FREE Resource

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following correctly declares a pointer to an integer in C++?

int pointer;

int *pointer;

pointer int*;

int &pointer;

Answer explanation

To declare a pointer to an integer, we use after the data type: int pointer;. This means pointer can store the memory address of an integer.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What is the output of the following code?

num

10

ptr

&num

Answer explanation

To declare a pointer to an integer, we use after the data type: int pointer;. This means pointer can store the memory address of an integer.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which operator is used to get the address of a variable in C++?

*

&

@

#

Answer explanation

The ampersand (&) is used to get the memory address of a variable. For example, &x gives the address of variable x.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the relationship between a pointer and an array in C++?

Pointers cannot access array elements.

A pointer can point to only the last element of the array.

Array name is a constant pointer to the first element.

Arrays do not work with pointers.

Answer explanation

In C++, the name of the array acts like a pointer to the first element. That’s why you can use pointer arithmetic to access array elements.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the new and delete operators in C++?

To perform multiplication and division.

To create and remove functions.

To allocate and free memory during runtime.

To declare variables.

Answer explanation

The new operator is used to allocate memory dynamically (during program running time), and delete is used to free that memory when it is no longer needed.