[CP 2] M5 - Pointers and Dynamic Arrays

studied byStudied by 1 person
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 66

flashcard set

Earn XP

Description and Tags

67 Terms

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

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

int a \= 100, b \= 200;

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

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

*

@

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

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

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

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

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

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

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

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

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

string s, *sp \= 0;

int *pi \= 0;

int *ip;

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

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

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

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

\#include
New cards
27
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
New cards
28
by applying the dereference operator
What is used for accessing the contents of memory location whose address is stored in a pointer variable?
New cards
29
143
What is the output of the given program?

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

\#include
New cards
31
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
New cards
32
dynamic array declaration
double * p \= new double [45]; is an example of:
New cards
33
100 200 300 400 500
What is the output of the following program?

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


int

float

double

all of the mentioned
New cards
35
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;

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

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

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

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

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

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

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

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

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

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

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

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

\#include
New cards
50
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?
New cards
51
Pizza
What is the output of the following code?

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

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

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

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

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

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

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

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

Explore top notes

note Note
studied byStudied by 310 people
359 days ago
5.0(3)
note Note
studied byStudied by 6 people
476 days ago
5.0(1)
note Note
studied byStudied by 11 people
83 days ago
5.0(1)
note Note
studied byStudied by 64 people
38 days ago
5.0(1)
note Note
studied byStudied by 89 people
993 days ago
5.0(1)
note Note
studied byStudied by 88 people
620 days ago
5.0(1)
note Note
studied byStudied by 16 people
376 days ago
5.0(1)
note Note
studied byStudied by 100 people
769 days ago
4.0(1)

Explore top flashcards

flashcards Flashcard (34)
studied byStudied by 5 people
298 days ago
5.0(1)
flashcards Flashcard (30)
studied byStudied by 4 people
656 days ago
4.5(2)
flashcards Flashcard (220)
studied byStudied by 2 people
103 days ago
5.0(1)
flashcards Flashcard (93)
studied byStudied by 8 people
39 days ago
5.0(1)
flashcards Flashcard (56)
studied byStudied by 6 people
754 days ago
5.0(1)
flashcards Flashcard (137)
studied byStudied by 14 people
170 days ago
5.0(1)
flashcards Flashcard (254)
studied byStudied by 51 people
168 days ago
5.0(1)
flashcards Flashcard (26)
studied byStudied by 15 people
747 days ago
5.0(1)
robot