34) Which of the following arithmetic operations is allowed on pointer variables?
| a. |
Modulus |
|
| b. |
Multiplication |
|
| c. |
Increment |
|
| d. |
Division |
35) In a two-dimensional array, the elements are arranged in a table form.
True
False
36)
In C++, which is the proper use of the indirection operator.
|
int *ptr |
||
|
int &ptr |
||
|
int ptr[] |
||
|
None of the above |
37) The statement int list[25]; declares list to be an array of 26 components, since the array index starts at 0.
True
False
38) A pointer is a variable which contains the address in memory of another variable
True
False
39)
In the statement
int* p, q;
p and q are pointer variables.
True
False
34) Which of the following arithmetic operations is allowed on pointer variables? a. Modulus b. Multiplication...
Question 17 2 pts A pointer is: A keyword used to create variables A variable that stores address of an instruction A variable that stores address of other variable A macro defined as a preprocessor directive. 2 pts Question 18 The operator used to get value at address stored in a pointer variable is: O& && O II Question 19 2 pts In the following code what is 'P: typedef char *charp; const charp P; Pis a constant Pis a...
Some pointer arithmetic is allowed. Which of the following arithmetic operators is allowed? (can have multiple answers) a) pointer + integer b) pointer - pointer c) pointer - integer d) integer + pointer e) integer * pointer Which statement correctly defines a vector object for holding Dealer objects? a.Dealer vector v; b.Dealer<vector> v; c.vector<Dealer> v; d.vector v<Dealer>; One of the following statements dynamically allocates an array of floats having size SIZE. a.float array; b.float *array[SIZE]; c.float array = new float[SIZE];...
TRUE/FALSE 1. If pl is an integer pointer variable, with the value of 1000, pl++ changes P1 to point to the memory location 1001. ANSWER: T 2. When you return a dynamic array to the freestore, you must include the number of elements in the array 3. You can assign an array to a pointer variable. 4. The size of dynamic arrays must be declared at compile time. 5. int *pl; declares a static variable. ANSWER: F ANSWER: F ANSWER:...
Which of the following function calls are syntactically correct given the variables and function header below? Select all that apply. int x=0, *ptr1; ptr1 = &x; void makeNegative(int *val) makeNegative(*ptr1); makeNegative(ptr1); makeNegative(x); makeNegative(&x); Which of the following statements will dynamically allocate memory for an array with 10 elements? int *ptr = int[10]; int *ptr[10]; int *ptr[10] = new int[10]; Identify all of the smart pointer types. Select all that apply. dynamic weak unique shared Which of the following statements will free...
1.What will the following statement output? cout << &num1; A)None of these B)the value stored in the variable named num1 C)the number 1 D)the memory address of the variable named num1 E)the string &num1 2. What will the following code output? int number = 888; int *var = &number; cout << var << endl; A)the address of number B)an asterisk followed by 8888 C)8888 D)an asterisk followed by the address of number 3. Assuming ptr is a pointer variable, what...
14) Given: int grade[4]; grade and &grade[0] can be interchangeable. True False 15) char val[3]; char *ptr; ptr = &val[2]; a. will assign the value in val[2] to the pointer b. will assign the address of val[2] to the pointer c. results both a and b d. none 16) In C++, you declare a pointer variable by using the ____ symbol. a. @ b. * c. # d. & 17) Which of the following correctly declares...
1) Using the dereferencing operator in pointers will return an address of a memory location. True False 2) The data type of a variable in a return statement must match the function type. True False 3) Given the declaration int *p, myArray[5]; The statement p = myArray; assigns the base address of the array to p. True False 4) Suppose that gamma is an array of 50 components of type int and j is an int variable. Which of the...
Question 22 4 pts In the statement: Int'. p and q are pointer variables. True False D Question 23 4 pts If a user-defined class object that uses mathematical operators to pass to the template function, the class must contain code for the primitive data types the constructor the overloaded operators the try/catch blocks Question 24 4 pts Afriend function is a function that is not part of a class but has access to the class's private members as well...
Question 2 [5 points) State if each of the below statements is True or False 1 2 3 The Compiler skips comments. A function can return a value of type array. An array index starts with 1. Pass by value is the default in CH, except when passing arrays as arguments to function The default storage class for local variables is static. A pointer provides an indirect means of accessing the value of a particular data item The logical operators...
#include <stdio.h> int main(int argc, char *argv[]) { char a, *pc, c[9]; int i, *pk, k[9]; a='z'; pc=&(c[8]); pk=&(k[0]); for (i=0; i<9; i++) { *pc=a-(char)i; pc--; *pk=(int)a-i; pk++; } return 0; }//end of main Answer the below questions with the above code Write out the memory map for the above C code in the following table. For array variables, list the address range for the entire array. Assume the memory address starts from 100, that is, the address for a...