(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 Plus Mylab Programming With Pearson Etext -- Access Card Package (10th Edition)
- Trace these print statements using the following arrays. Write "error", if an error occurs.arrow_forwardWhat is the data type of pointer variables? Suppose that we don‘t know the name of a variable but we do know its address. Can we access the contents of that variable? Explain briefly. Subject: C++arrow_forward- in this exercise, please do not include and use string class. The function is using only array notation and manipulation.- string functions such as strlen is not allowed.- it should not have multiple return statements in the same function- there should be no global variable.- the function should not traverse the arrays more than once (e.g. looping through the array once only) A C++ PROGRAM named "isTheLastNumberTheMax" that accepts an array of integers and its size. It will return true if the last number in the array is the maximum number in that array and false otherwise. In addition, it also returns another boolean to indicate whether this list contains more than one maximum value.For example, if this is called with the array of {10, 20, 30, 40, 50}, it will return true and falseIf this is called with the array of {50, 10, 20, 30, 40, 50}, it will return true and true. A C++ PROGRAM named "changeCase" that takes an array of characters terminating by NULL character (C-string) and…arrow_forward
- Please solve and show steps, work, and information related to this problem. Thank you. The following C++ code performs a set of various arithmetic operations using both pointers and references: Fill in a memory table that shows the final values for both function a and function b. Indicate the final values of each parameter, passed in variable(s), and the return value of the function. Provide a separate copy of this memory table for each function.arrow_forward1-Write a C++ program to input elements in array and sort array elements in descending order. How to sort array in descending order in using pointers.Use function to print out the original and sorted arrays, Example Input Input size of array: 10 Input array elements: 20, 2, 10, 6, 52, 31, 0, 45, 79, 40 Output Array sorted in descending order: 79 ,52,45,40,31,20,10,6,2,0arrow_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
- Write C++ statements to do the following:i.Declare an empty array DATA to hold 7 double floating values.ii.Assign value 5.7 to the last element in the array.iii.Display the sum of the first two elements without using extra memory variable.iv.Write a while-loop that computes the sum of all elements in the array.v.Write a while-loop that finds the minimum element in the array.vi.Randomly generate an index and display the element at this (randomly generated) index in the array.vii.Use an array initializer to declare another array with initial values 5.78, 12.69, 10.45, and19.0arrow_forwardPLEASE DO YOUR OWN CODING NO COPYING Write an assembly program to compute the following expressions - Create a DWORD array named ‘z’ of size 3 using DUP operator. Leave the array ‘z’ uninitialized.You can denote the items in the array as [�!, �", �#], where �! is the first item, �" is the second item,�# is the third item- Update each array item using the following expressions. �! = � + 130�" = � + � − �!�# = � + � − 13 - Where x, y, r are 16-bit integer memory variables.- x = 10, y = 15, r = 4- Use mov, movzx, movsx, add, sub instructions only.- (hint: Do not alter the value of x, y and r during the computation. Transfer them to appropriate registers to docomputation)- At the end, open memory window to see the variable z stored in memory (little endian format).- If you code correctly, �! = 140 in decimal, �" = −115 in decimal, �# = 1 in decimal § Screenshot of the code and memory window showing the content of the variable z (little endianformat).arrow_forwardIn Assembly 1. Write code that traverses (or goes through) the following array using the ESI register: .dataarrayOfWords 1020h, 3040h, 5060h, 7080h, 9090h 2. Write code that again, traverses the array in Question #1, but this time using a loop. 3. Using the same array in Question #1, access the 3rd element in the array (the one with subscript 2)4. Declare a variable that works as a pointer to BYTEs.arrow_forward
- I CROSS CHECK FROM OTHER SOURCE! DO NOT COPY SOMEONE ELSE AND PLEASE BE SURE TO FOLLOW THE INSTRUCTION TO INCLUDE ALL THAT IS NEEDED!! The code should contain all structure with array, function, and pointer!!!!!! Instruction: Make a C-program with a flowchart using structure with array, function, and pointer that will compute for the average grade of the student. The user will define how many student record will be inputted. Here are the following parameters needed: Name, Student Number, Degree, Course Name 1, Course Name 2, Course Name 3, Course 1 grade, Course 2 grade, Course 3 grade, Average. I have attached the sample output here. The code should contain all structure with array, function, and pointer!!!!!! Unable to combine all necessary inputs will result to unhelpful! Please make sure that the program will work if the user will input 2 or more words.arrow_forwardI CROSS CHECK FROM OTHER SOURCE! DO NOT COPY SOMEONE ELSE AND PLEASE BE SURE TO FOLLOW THE INSTRUCTION TO INCLUDE ALL THAT IS NEEDED!! The code should contain all structure with array, function, and pointer!!!!!! Instruction: Make a C-program with a flowchart using structure with array, function, and pointer that will compute for the average grade of the student. The user will define how many student record will be inputted. Here are the following parameters needed: Name, Student Number, Degree, Course Name 1, Course Name 2, Course Name 3, Course 1 grade, Course 2 grade, Course 3 grade, Average. I have attached the sample output here. The code should contain all structure with array, function, and pointer!!!!!! Unable to combine all necessary inputs will result to unhelpful!arrow_forwardWrite complete C++ code to display numbers larger than n in an array. In your code, write a function that accepts three arguments: an array, the size of the array, and a number n . Assume that the array contains integers. Call the function from main in your code. The function should display all of the numbers in the array that are greater than the number n . You could use a named constant for the value of n or collect it from the user. In main declare an array using an initialization list. Sample output is: Numbers greater than 4 in the array are: 5, 17, 10, 12arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr