(Write C++ Statements) For each of the following, write C++ statements that perform the
specified task. Assume that unsigned integers are stored in four bytes and that the starting address of the built-in array is at location 1002500 in memory.
a) Declare an unsigned int built-in array values with five elements initialized to the even integers from 2 to 10. Assume that the constant size has been defined as 5.
b) Declare a pointer vPtr that points to an object of type unsigned int.
c) Use a for Statement to display the elements of built-in array values using array sub-Script notation.
d) Write two separate statements that assign the starting address of built-in array values to pointer variable vPtr.
e) Use a for statement to display the elements of built-in array values using pointer/offset notation.
f) Use a for statement to display the elements of built-in array values using pointer/offset notation with the built-in array's name as the pointer.
g) Use a for statement to display the elements of built-in array values by subscripting the pointer to the built-in array.
h) Refer to the fifth element of values using array subscript notation, pointer/offset notation with the built-in array name's as the pointer, pointer subscript notation and pointer/offset notation.
i) What address is referenced by vPtr + 3? What value is stored at that location?
j) Assuming that vPtr points to values [4], what address is referenced by vPtr - = 4? What value is stored at that location?
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
C++ How to Program (10th Edition)
- ii) Write a explicit custom comparator that sorts the array in descending order. Test the custom comparator taking a random array. C++arrow_forwardc++ : rewrite this code , to be unique . In which the output will stay same same. #include <iostream>#include <stdint.h>using namespace std; class arr{private: int size_arr; //To store the size of the array char *begin; //Pointer for dynamic allocation of memory int capacity; //To store the capacity of the elements in the arraypublic: arr(int n); //constructor (default) for creating an array int insert_arr(char x); //To insert an element x in the array int remov_arr(int i); //To remove an element from position i void display(); void displayAtPos(int i);//Function to display a character at position i}; arr::arr(int n){ size_arr = n; begin = new char[size_arr]; capacity = 0;} int arr::insert_arr(const char x){ if(capacity >= size_arr){ cout << "Array Full!" << endl; return -1; } begin[capacity++] = x; //One element is added, so increment the…arrow_forward1)Please do it in C++ languagearrow_forward
- Required part 4,5,6,7arrow_forward4)Please do it in C++ languagearrow_forwardNeed fun Language code please. The Programs:- (File: count.fun) Write a program which counts from 1 to 10, printing each number on a line by itself. (File: array.fun) For this program you have two requirements: Create a function which takes two arguments, an array and the number of elements in the array. Have this function print the contents of the array, one entry per line. Have the program read in an array of 10 numbers. Next, reverse the contents of the array. Finally have your program print out the contents of the array, one per line.arrow_forward
- c) Using pointer notation, write a function in C which copies the contents of one char array, s2 to another char array, sl. The function prototype is given below. void copy(char s1, const char *s2);arrow_forwardwrite C++ statements that perform the specified task. Assume that unsigned integers are stored in four bytes and that the starting address of the built-in array is at location 1002500 in memory. " Write two separate statements that assign the starting address of built-in array values to pointer variable vPtr ."arrow_forward(Airplane Seating Assignment) | Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with six seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business class, and rows 8 through 13 are economy class. Use two parallel arrays: a one-dimensional array to store the row number of the seats (Row #) a two-dimensional array of 13 rows and 6 columns to store the seat assignments (*) and seat letters (A-F) Your program must prompt the user to enter the following information: Reserve a seat (Yes (Y/y) or No (N/n)) Assign ticket type (first class (F/f), business class (B/b), or economy class (E/e)) Select desired seat (1-13 and A-F) Your program must contain at least the following functions: a function to initialize the seat plan. a function to show the seat assignments. a function to show the menu to assign a seat. a function to assign and select your desired seat. a function for each ticket type that determines if a seat…arrow_forward
- (Airplane Seating Assignment) | Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with six seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business class, and rows 8 through 13 are economy class. Use two parallel arrays: a one-dimensional array to store the row number of the seats (Row #) a two-dimensional array of 13 rows and 6 columns to store the seat assignments (*) and seat letters (A-F) Your program must prompt the user to enter the following information: Reserve a seat (Yes (Y/y) or No (N/n)) Assign ticket type (first class (F/f), business class (B/b), or economy class (E/e)) Select desired seat (1-13 and A-F) Your program must contain at least the following functions: a function to initialize the seat plan. a function to show the seat assignments. a function to show the menu to assign a seat. a function to assign and select your desired seat. a function for each ticket type that determines if a seat…arrow_forward(Airplane Seating Assignment) | Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with six seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business class, and rows 8 through 13 are economy class. Use two parallel arrays: a one-dimensional array to store the row number of the seats (Row #) a two-dimensional array of 13 rows and 6 columns to store the seat assignments (*) and seat letters (A-F) Your program must prompt the user to enter the following information: Reserve a seat (Yes (Y/y) or No (N/n)) Assign ticket type (first class (F/f), business class (B/b), or economy class (E/e)) Select desired seat (1-13 and A-F) Your program must contain at least the following functions: a function to initialize the seat plan. a function to show the seat assignments. a function to show the menu to assign a seat. a function to assign and select your desired seat. a function for each ticket type that determines if a seat…arrow_forward2) For each of the following, write C++ statements that perform the specified task.a) Declare a built-in array of type unsigned int called values with five elements, andinitialize the elements to the even integers from 2 to 10.b) Declare a pointer vPtr that points to a variable of type unsigned int.c) Write two separate statements that assign the starting address of array values to pointervariable vPtr.d) Use a for statement to print the elements of array values using pointer/offset notation.e) Refer to the fifth element of values using pointer subscript notation.f) Assume that unsigned integers are stored in two bytes and that the starting address of thearray is at location 1002500 in memory.• If vPtr points to the first element of array values, then what address is referenced byvPtr + 3? (manually calculate)• What value is stored at that location?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education