Save
Upgrade to remove ads
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
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

CP2

Formative Assessment 5

QuestionAnswer
A void pointer can point to which type of objects? int all of the mentioned float double all of the mentioned
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; } 1 0 40 20 20
When does the void pointer can be dereferenced? Using the delete keyword None of the mentioned When it doesn’t point to any value When it cast to another type of object When it cast to another type of object
It stores the memory address as its value. Pointer Variable Identifier Data Type Pointer
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"; } Pizza Pizza Pizza Error 0 Pizza Pizza
A symbol used to access the value of an address & # * $ *
Which of the following is NOT a way to declare a pointer variable? string mystring *; string * mystring; string* mystring; string *mystring; string mystring *;
Choose the right option: string* x, y; x is y x is a pointer to a string, y is a string both x and y are pointer to string types this statement produces an error x is a pointer to a string, y is a string
What is the output of the following code? #include <iostream> using namespace std; int main() {     string food = "Pizza";     string* ptr = &food;       cout << food << "\n";    return 0; } foog Error ptr Pizza Pizza
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; } fg abcd cdef defg fg
What is the output of the given program? #include <iostream> using namespace std; int main() {     int *ptr = new int;     int a = 143;     ptr = &a;     cout << *ptr << endl;     return 0; } Error 143 0 A memory address 143
To create a dynamic array, you have to use: Pointer Variable Array All of the given new operator new operator
How many number 5? int main() {     int n;     cin >> n;     int * p = new int[n];     for (int i = 0; i<n;i++)   {    p[n] = 5;    cout << p[n] << " ";  } delete []p; return 0; } It depends on user input It will display other number It depends on user input
What is used for accessing the contents of memory location whose address is stored in a pointer variable? By applying the dereference operator By applying an array By applying some special function By applying the address operator & By applying the dereference operator
What is the output of the following? #include <iostream> using namespace std; int main() {     int * foo = new int [5];     foo[0] = 8;     cout << foo [0];     delete[] foo;     return 0; } NULL Error 8 0 8
How a static array is declared? string s; float * p = new float [5]; int n; float a [10]; float a [10];
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 i = 0; i < 5; i++)  {      cout << foo[i] << " ";  }     delete[] foo;     return 0; } 5 0 1 2 3 4 5 Error 1 2 3 4 5
double * p = new double [45]; is an example of: Function declaration Dynamic array declaration Static array declaration Multi-dimensional array declaration Dynamic array declaration
#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; } 45 90 0 error 90
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; } fg defg abcd cdef fg
What is the output of the following code? #include <iostream> using namespace std; int main() {     string food = "Pizza";     string* ptr = &food;       cout << food << "\n";    return 0; } Error ptr foog Pizza Pizza
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; } 40 20 0 1 20
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"; } Pizza Pizza 0 Pizza Error Pizza Pizza
What is the declaration for the pointer that points to a variable of type int? int p; int(p); int *p; INT *p; int *p;
Which of the following is NOT a way to declare a pointer variable? string *mystring; string mystring *; string* mystring; string * mystring; string mystring *;
Complete the given code: #include <iostream> using namespace std; int main() {     int var1 = 17;     cout << ________ << endl;      return 0; } var1 var1(17) *var1 &var1 var1
When does the void pointer can be dereferenced? Using the delete keyword When it cast to another type of object None of the mentioned When it doesn’t point to any value When it cast to another type of object
It is a pointer not associated with any data types data type operator void pointer identifier void pointer
A void pointer can point to which type of objects? double float all of the mentioned int all of the mentioned
What is used for accessing the contents of memory location whose address is stored in a pointer variable? By applying the address operator & By applying an array By applying some special function By applying the dereference operator By applying the dereference operator
int main() {     int n;     n = 3;     int * p = new int[n];     for (int i = 0; i<n;i++)     {         p[n] = 10;         cout << p[n] << " ";     }     delete []p;     return 0; } 101010 Error 3 10 10 10 10 10 10 10 10
Denotes a request for memory allocation on the Free Store address operator new operator delete operator dereferencing operator new operator
To create a dynamic array, you have to use: Pointer Variable Array new operator All of the given new operator
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 i = 0; i < 5; i++) {   cout << foo[i] << " "; }   delete[] foo;   return 0; } 0 5 Error 1 2 3 4 5 1 2 3 4 5
How a static array is declared? float * p = new float [5]; string s; int n; float a [10]; float a [10];
#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; } 90 0 error 45 90
What is the output of the following? #include <iostream> using namespace std; int main() {     int * foo = new int [5];     foo[0] = 8;     cout << foo [0];     delete[] foo;     return 0; } Error NULL 0 8 8
Which of the following is NOT true about static arrays? Memory space is allocated at runtime Located in Stack Memory space Fixed size Memory space is allocated during compile time Memory space is allocated at runtime
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"; } Pizza 0 Pizza Pizza Error Pizza Pizza
It stores the memory address as its value. Data Type Variable Pointer Identifier Pointer
A symbol used to access the value of an address # * & $ *
When does the void pointer can be dereferenced? Using the delete keyword None of the mentioned When it doesn’t point to any value When it cast to another type of object When it cast to another type of object
A void pointer can point to which type of objects? int all of the mentioned double float all of the mentioned
It is a pointer not associated with any data types identifier operator data type void pointer void pointer
Which of the following is a reference operator? & @ * & &
What is the declaration for the pointer that points to a variable of type int? Group of answer choices int(p); int p; int *p; INT *p; int *p;
Complete the given code: #include <iostream> using namespace std; int main() {     int var1 = 17;     cout << ________ << endl;      return 0; } Group of answer choices *var1 &var1 var1(17) var1 var1
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; } abcd cdef defg fg fg
#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] << " ";   }   delete []p;   return 0; } 10 10 10 101010 3 10 10 Error 10 10 10
What is the output of the following? #include <iostream> using namespace std; int main() {     int * foo = new int [5];     foo[0] = 8;     cout << foo [0];     delete[] foo;     return 0; } NULL Error 8 0 8
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 i = 0; i < 5; i++) {     cout << foo[i] << " ";  } delete[] foo; return 0; } 1 2 3 4 5 0 5 Error 1 2 3 4 5
How a static array is declared? float * p = new float [5]; float a [10]; int n; string s; float a [10];
Which of the following is NOT true about dynamic arrays? Memory space is allocated at runtime Dynamic size Memory space is allocated during compile time Located in Heap memory space Memory space is allocated at runtime
What is the output of the program? #include <iostream> using namespace std; int main() {     int *ptr = new int;     int a = 143;     ptr = &a;     cout << ptr << endl;     return 0; } 0 143 A memory address Error A memory address
double * p = new double [45]; is an example of: Static array declaration Function declaration Multi-dimensional array declaration Dynamic array declaration Dynamic array declaration
Denotes a request for memory allocation on the Free Store delete operator address operator new operator dereferencing operator new operator
How many number 5? int main() {     int n;     cin >> n;     int * p = new int[n];     for (int i = 0; i<n;i++)   {    p[n] = 5;    cout << p[n] << " ";  } delete []p; return 0; } It depends on user input It will display other number It depends on user input
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"; } Pizza 0 Pizza Pizza Error Pizza Pizza
Which of the following is illegal? int *ip; int i; double * dp = &i; int *pi = 0; string s, *sp = 0; int i; double * dp = &i;
Which of the following is NOT a way to declare a pointer variable? string *mystring; string* mystring; string * mystring; string mystring *; string mystring *;
Complete the given code: #include <iostream> using namespace std; int main() {     int var1 = 17;     cout << ________ << endl;      return 0; } *var1 &var1 var1 var1(17) var1
Which of the following is a reference operator? @ * & & &
It stores the memory address as its value. Pointer Data Type Identifier Variable Pointer
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; } 0 1 40 20 20
0x7fffe867d790 is an example of: boolean Data type Memory Address Parameter Memory Address
What will happen in this code? int a = 100, b = 200; int *p = &a, *q = &b; p = q; a is assigned to b p now points to b q now points to a b is assigned to a p now points to b
What is the output of the program? #include <iostream> using namespace std; int main() {     int *ptr = new int;     int a = 143;     ptr = &a;     cout << ptr << endl;     return 0; } 143 Error A memory address 0 A memory address
It stores the memory address as its value Pointer Identifier Data type Variable Pointer
double * p = new double [45]; is an example of: Function declaration Dynamic array declaration Static array declaration Multi-dimensional array declaration Dynamic array declaration
#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; } 45 error 0 90 90
#include <iostream> using namespace std; int main() {     int a[2];     a[0] = 12;     a[1] = 12;     int a[3];     a[0] = 12;     a[1] = 12;     a[3] = 12;     return 0; } 12 Error None 12 12 12 12 12 Error
#include <iostream> using namespace std; int main() {     int *ptr = new int;     int a = 143;     ptr = &a;     cout << *ptr << endl;     return 0; } 0 A memory address 143 Error 143
What operator is used to free allocated memory? address operator new operator dereferencing operator delete operator delete operator
Created by: Heirm
 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards