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];
d.float *array = new float[SIZE];
Which of the following statements declare two-dimensional array?
a.int a[];
b.int a[5][6];
c.int a[][];
d.int a[][4];
e.None of the above
The below operations are allowed, pointer only support + and -
and not *
a) pointer + integer
b) pointer - pointer
c) pointer - integer
d) integer + pointer
c.vector<Dealer> v; is the correct way to define vector to
store Dealer objects
d.float *array = new float[SIZE]; is the correct way;
b.int a[5][6]; is the correct statement; we need to mention the
size of first and second dimensions is square brackets
Some pointer arithmetic is allowed. Which of the following arithmetic operators is allowed? (can have multiple...
Multiple choice questions 1. A variable that is shared by all objects of a class is called_________? A.Static variable B. Const variable C.Member variable D. None of the above 2. Each object of a class has its own copy of the class's: A. member functions B. static member variables C. instance member variables D. A & C E. A & B 3. In a vector, which of the following statements is true? (can have multiple answers) a) Indexing vector access...
Which of these function correctly defines the function g(), which should return a pointer to a dynamically allocated array? a. int g(int size) { int *ptr = new int [size]; return *ptr;} b. int* g (int size) { int data [size]; int *ptr =data; return ptr;} c. int* g(int size) { int *ptr = new int[size]; return ptr;} d.int g(int size { int *ptr = new int [size]; return ptr;} e. int g (int size) { int data[size]; int *ptr...
I have some questions about pointers/pointer arithmetic in C++ 1) Pointers and Pointer Arithmetic a.) What is the difference between statically allocated arrays and dynamically allocated arrays (be brief) b.) Which of the following pointers can be used for a dynamically allocated array? (Circle) char ptr; char * ptr; char ptr *; char ptr[]; char [] ptr; c.) Show now, using that pointer, how to dynamically allocate array of characters of size 10: (don't use malloc) d.) Which of the...
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...
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:...
You will write the following files: mystack.h - contains the class definition for the mystack class. mystack.cpp - contains the definitions for member functions of the mystack class. inpost.cpp - contains your convert() function. inpost.h - contains the function prototype for convert() so that the main() can call it. Each of the files (with the exception of inpost.h) is described in more detail below. All header files should contain header guards to prevent them from being included multiple times in...
Please, explain clearly each line of code with your answers. Question 1 Consider the following code snippet: int ctr = 0; int myarray[3]; for (int i = 0; i < 3; i++) { myarray[i] = ctr; ctr = ctr + i; } cout << myarray[2]; What is the output of the code snippet? Question 2 Consider the following code snippet: int cnt = 0; int numarray[2][3]; for (int i = 0; i < 3; i++) { for (int j =...
Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839. Also, review pointers and dynamic memory allocation posted here under Pages. For sorting, you can refer to the textbook for Co Sci 839 or google "C++ sort functions". I've also included under files, a sample C++ source file named sort_binsearch.cpp which gives an example of both sorting and binary search. The Bubble sort is the simplest. For binary search too, you can refer to...
WONT COMPILE ERROR STRAY / TEXT.H AND CPP PROGRAM SAYING NOT DECLARED HAVE A DRIVER WILL PASTE AT BOTTOM MOVIES.CPP #include "movies.h" #include "Movie.h" Movies *Movies::createMovies(int max) { //dynamically create a new Movies structure Movies *myMovies = new Movies; myMovies->maxMovies = max; myMovies->numMovies = 0; //dynamically create the array that will hold the movies myMovies->moviesArray = new Movie *[max]; return myMovies; } void Movies::resizeMovieArray() { int max = maxMovies * 2; //increase size by 2 //make an array that is...
Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p; int i; int k; i = 42; k = i; p = &i; After these statements, which of the following statements will change the value of i to 75? A. k = 75; B. *k = 75; C. p = 75; D. *p = 75; E. Two or more of the answers will change i to 75. Consider the following statements: int i =...