CCS0007 Pointers
Quiz yourself by thinking what should be in
each of the black spaces below before clicking
on it to display the answer.
Help!
|
|
||||
---|---|---|---|---|---|
A symbol used to access the value of an address | show 🗑
|
||||
When does the void pointer can be dereferenced? | show 🗑
|
||||
show | fg
🗑
|
||||
Which of the following is a reference operator? | show 🗑
|
||||
show | 40
🗑
|
||||
What is the output of the following? #include <iostream> using namespace std; int main() { int var = 20; int *ip; ip = &var; cout << *ip << endl; return 0; } | show 🗑
|
||||
Which of the following is NOT true about static arrays? | show 🗑
|
||||
show | Memory space is allocated during compile time
🗑
|
||||
show | Heap
🗑
|
||||
show | 8
🗑
|
||||
show | &
🗑
|
||||
What is the output of the following program? #include <iostream> using namespace std; int main() { string food = ""Pizza""; string * ptr = &food; cout << food << "" ""; cout << *ptr << ""\n""; } | show 🗑
|
||||
show | string mystring *;
🗑
|
||||
#include <iostream> using namespace std; int main() { string food = ""Pizza""; string* ptr = &food; cout << food << ""\n""; return 0; } | show 🗑
|
||||
show | void pointer
🗑
|
||||
What operator is used to free allocated memory? | show 🗑
|
||||
show | 143
🗑
|
||||
show | A memory address
🗑
|
||||
Denotes a request for memory allocation on the Free Store | show 🗑
|
||||
"What is the output of the following? #include <iostream> using namespace std; int main() { int * foo; foo = new int [5]; foo[0] = 1; foo[1] = 2; foo[2] = 3; foo[3] = 4; foo[4] = 5; for (int | show 🗑
|
||||
"What is the output of the following program? #include <iostream> using namespace std; int main() { int n; n = 3; int * p = new int[n]; for (int i = 0; i<n;i++) { p[n] = 10; cout << p[n] << | show 🗑
|
||||
show | var1
🗑
|
||||
It stores the memory address as its value. | show 🗑
|
||||
What is the declaration for the pointer that points to a variable of type int? | show 🗑
|
||||
show | Memory space is allocated at runtime
🗑
|
||||
show | float a [10];
🗑
|
||||
show | Memory space is allocated during compile time
🗑
|
||||
What is used for accessing the contents of memory location whose address is stored in a pointer variable? | show 🗑
|
||||
show | Heap
🗑
|
||||
#include <iostream> using namespace std; int main() { int * foo = new int [5]; foo[0] = 8; cout << foo [0]; delete[] foo; return 0; } | show 🗑
|
||||
show | &
🗑
|
||||
show | Pizza Pizza
🗑
|
||||
Which of the following is NOT a way to declare a pointer variable? | show 🗑
|
||||
#include <iostream> using namespace std; int main() { string food = ""Pizza""; string* ptr = &food; cout << food << ""\n""; return 0; } | show 🗑
|
||||
It is a pointer not associated with any data types | show 🗑
|
||||
What operator is used to free allocated memory? | show 🗑
|
||||
#include <iostream> using namespace std; int main() { int *ptr = new int; int a = 143; ptr = &a; cout << ptr << endl; return 0; } | show 🗑
|
||||
Denotes a request for memory allocation on the Free Store | show 🗑
|
||||
show | 10 10 10
🗑
|
||||
show | Memory Address
🗑
|
||||
What will happen in this code? int a = 100, b = 200; int *p = &a, *q = &b; p = q; | show 🗑
|
||||
show | 11 11
🗑
|
||||
#include <iostream> using namespace std; int main() { int * foo; foo = new int [5]; foo[0] = 1; foo[1] = 2; foo[2] = 3; foo[3] = 4; foo[4] = 5 delete[] foo; cout ; return 0; } | show 🗑
|
||||
#include <iostream> using namespace std; int main() { int *p1 = new int(); int *p2 = new int(); int *p3 = new int(); *p1 = 45; p2 = p1; *p3 = *p1+*p2; cout << *p3 << endl; return 0; } | show 🗑
|
||||
Choose the right option: string* x, y; | show 🗑
|
||||
show | Dynamic array declaration
🗑
|
||||
A void pointer can point to which type of objects? | show 🗑
|
||||
To create a dynamic array, you have to use: | show 🗑
|
Review the information in the table. When you are ready to quiz yourself you can hide individual columns or the entire table. Then you can click on the empty cells to reveal the answer. Try to recall what will be displayed before clicking the empty cell.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.
Normal Size Small Size show me how
Normal Size Small Size show me how
Created by:
xhinvier