C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
Expert Solution & Answer
Book Icon
Chapter 12, Problem 18SA

Explanation of Solution

The program has been explained in the in-lined comments:

#include <iostream> 

using namespace std; 

int main()  

{  

    //declare int pointers

    int *intArrayPtr;

    int *temp;

    //creates an array of five components of type int and

    //stores the base address of the array 

    //into the pointer intArrayPtr

    intArrayPtr = new int[5];

    //contents of the base address of the array is 

    //assigned a value of 7 i.e. intArrayPtr[0] is 7

    *intArrayPtr = 7;

    //temp is assigned the value of intArrayPtr

    //so it also points to array base address

    //i.e. intArrayPtr[0]

    temp = intArrayPtr;

    //modify the contents of the array inside for loop

    for (int i = 1; i < 5; i++)

    {

        //increment pointer to the next address

        //i.e. next element in the array

        intArrayPtr++;

        //assign the value of the current element

        //pointed to by intArrayPtr with the value

        //on RHS ...

Blurred answer
Students have asked these similar questions
What does the following code?   void xxxx(int arr[], int index[], int n){int temp[n]; for (int i=0; i<n; i++)temp[index[i]] = arr[i]; for (int i=0; i<n; i++){arr[i] = temp[i];index[i] = i;}}
Your Friendly Array Neighbor   Program only in java not in python Create a Java program that takes an array called ar as an input that keeps track of arrays. Every day a new array is produced using the array of the previous day. On the n’th day, the following operations are performed on the array of day n – 1 to produce the array of day n:   -If an element is smaller than both left and right neighbor, then this element is incremented -If an element is bigger than both its left neighbor and its right neighbor, then this element is decremented. -The first and last elements should never change   Eventually after some days the array will not change, some examples:   Example: Input from user: ar = [6,2,3,4] Output from program: [6,3,3,4] After the first day the array is changed from [6,2,3,4] to [6,3,3,4] and no further operations may be completed.   Example: Input from user: ar = [1,6,3,4,3,5] Output from program: [1,4,4,4,4,5]   After the first day the array is changed from [1,6,3,4,3,5]…
In java: Develop a function that accepts an array of integers and returns their average. Develop a function that accepts an array of integers and a threshold value from the user. The function returns how many values in the array are strictly greater than the cutoff. Using the functions written for #1, #3, and #4, find the number of values above average in two randomly generated arrays.  Develop two functions:a. a function that returns the index of the maximum value in an array of integers passed by a caller, the caller prints the returned index and the value at that indexb. a function that returns the index of the alphabetically first value in an array of strings, the caller prints the returned index and the value at that inde Develop two functions:a. a function that swaps the alphabetically first value in an array of Strings with the first value in the array. Call this function twice on two different arrays of Strings; in the caller, use the function written for #2b to display…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education