[CP 2] M5 - Pointers and Dynamic Arrays

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/66

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

67 Terms

1
New cards
int *p;
What is the declaration for the pointer that points to a variable of type int?
2
New cards
20
What is the output of the following?

\#include
3
New cards
*
A symbol used to access the value of an address
4
New cards
&
A symbol used to determine the address of a variable
5
New cards
p now points to b
What will happen in this code?

int a \= 100, b \= 200;

int *p \= &a, *q \= &b;

p \= q;
6
New cards
&
Which of the following is a reference operator?
&

*

@

&
7
New cards
string mystring *;
Which of the following is NOT a way to declare a pointer variable?
8
New cards
All of the given
To create a dynamic array, you have to use:

"Pointer Variable
All of the given
Array
New operator"
9
New cards
It depends on user input
How many number 5 will display based on the given program?

\#include
10
New cards
Memory space is allocated at runtime
Which of the following is NOT true about static arrays?
11
New cards
Error
What is the output of the program?

\#include
12
New cards
143
What is the output of the given program?

\#include
13
New cards
A memory address
What is the output of the program?

\#include
14
New cards
1 2 3 4 5
What is the output of the following?

\#include
15
New cards
Pointer
It stores the memory address as its value.
16
New cards
90
What is the output of the following?

\#include
17
New cards
100 200 300 400 500
What is the output of the following program?

\#include
18
New cards
int *ip;
Which of the following is illegal?

string s, *sp \= 0;

int *pi \= 0;

int *ip;

int i; double * dp \= &i;
19
New cards
Pizza Pizza
What is the output of the following program?

\#include
20
New cards
var1
Complete the given code:

\#include
21
New cards
void pointer
It is a pointer not associated with any data types
22
New cards
new operator
Denotes a request for memory allocation on the Free Store
23
New cards
float a [10];
How a static array is declared?
24
New cards
Heap
Dynamically allocated memory is allocated on \___________________
25
New cards
error
What is the output of the given program?

\#include
26
New cards
8
What is the output of the following?

\#include
27
New cards
memory space is allocated during compile time
Which of the following is NOT true about dynamic arrays?
Group of answer choices

Memory space is allocated during compile time

Memory space is allocated at runtime

Located in Heap memory space

Dynamic size
28
New cards
by applying the dereference operator
What is used for accessing the contents of memory location whose address is stored in a pointer variable?
29
New cards
143
What is the output of the given program?

\#include
30
New cards
90
What is the output of the following?

\#include
31
New cards
x is a pointer to a string, y is a string
Choose the right option:

string* x, y;

Group of answer choices

x is y

x is a pointer to a string, y is a string

this statement produces an error

both x and y are pointer to string types
32
New cards
dynamic array declaration
double * p \= new double [45]; is an example of:
33
New cards
100 200 300 400 500
What is the output of the following program?

\#include
34
New cards
ALL OF THE MENTIONED
A void pointer can point to which type of objects?


int

float

double

all of the mentioned
35
New cards
fg daw
What is the output of this program?

\#include < iostream \>

using namespace std;

int main()

{

char *ptr;

char Str[] \= "abcdefg";

ptr \= Str;

ptr +\= 5;

cout << ptr;

return 0;

}
36
New cards
45241
\#include
37
New cards
Pizza Pizza
What is the output of the following program?

\#include
38
New cards
40
What is the output of the following?

\#include
39
New cards
20
What is the output of the following?

\#include
40
New cards
delete operator
What operator is used to free allocated memory?
41
New cards
40461
What is the output of the following program?

\#include
42
New cards
it depends on user input
How many number 5 will display based on the given program?

\#include
43
New cards
100 200 300 400 500
What is the output of the following program?

\#include
44
New cards
error
What is the output of the program?

\#include
45
New cards
8
What is the output of the following?

\#include
46
New cards
1 2 3 4 5
What is the output of the following?

\#include
47
New cards
error
What is the output of the given program?

\#include
48
New cards
a memory address
What is the output of the program?

\#include
49
New cards
Pizza Pizza
What is the output of the following program?

\#include
50
New cards
None of the mentioned

"By its definition a void pointer does not point to data of a specific type. Therefore you cannot de-reference a void pointer


when it cast to another type of object yung tamang sagot"
When does the void pointer can be dereferenced?
51
New cards
Pizza
What is the output of the following code?

\#include
52
New cards
Pizza Pizza
What is the output of the following program?

\#include
53
New cards
Pizza
What is the output of the following code?

\#include
54
New cards
20
What is the output of the following?

\#include
55
New cards
new and delete
what functions are used in dynamic memory allocation in C++?
56
New cards
45241
What is the output of the following?

\#include
57
New cards
40461
What is the output of the following program?

\#include
58
New cards
90
What is the output of the following?

\#include
59
New cards
100 200 300 400 500
\#include
60
New cards
It depends on user input
How many number 5 will display based on the given program?

\#include
61
New cards
143
\#include
62
New cards
delete
to free the dynamically allocated array pointed by pointer-variable, use:
63
New cards
new
it is used to declare memory blocks at run time (dynamically)
64
New cards
dangling pointer
a pointer that no longer points to something valid on the heap
65
New cards
delete ptr;
what is the correct syntax for deleting a pointer named ptr:
66
New cards
new operator
It requests for the memory allocation in heap
67
New cards
call the pointer
the method of passing arguments to a function copies the address of an argument into the formal parameer