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 ...
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
C++ Programming: From Problem Analysis to Program Design
- int func(int a, int b) { return (aarrow_forwardint main() { int inStock[10][4]; int alpha[20]; int beta[20]; int gamma[4] = {11, 13, 15, 17}; int delta[10] = {3, 5, 2, 6, 10, 9, 7, 11,1, 8};. . .} a. Write the definition of the function setZero that initializes any onedimensional array of type int to 0. b. Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha. c. Write the definition of the function doubleArray that initializes the elements of beta to two times the corresponding elements in alpha. Make sure that you prevent the function from modifying the elements of alpha. d. Write the definition of the function copyGamma that sets the elements of the first row of inStock to gamma and the remaining rows of inStock to three times the previous row of inStock. Make sure that you prevent the function from modifying the elements of gamma. e. Write the definition of the function copyAlphaBeta that stores alpha into the first five rows of inStock and beta into the…arrow_forward#include <stdio.h> struct Single { int num; }; void printSingle(int f) { int binaryNum[33]; int i = 0; while(f>0) { binaryNum[i] = f % 2; f = f/2; i++; } for (int j=i-1; j>= 0; j--) { printf("%d",binaryNum[j]); } } int main() { struct Single single; single.num = 33; printf("Number: %d\n",single.num); printSingle(single.num); return 0; }arrow_forward#include using namespace std; int main() (double degree [6] [2] = {30,40,10,70, 20, 30, 60, 70, 30, 10, 10, 85); int buffer=degree[0][0]; for (int i=1;ibuffer) buffer=degree[i][0]; cout using namespace std; int main() { int j=1; while (j<=10) if ((j%3)==0) cout<arrow_forwardadd explanationarrow_forwardvoid mystery2(int list[], int length) { for (int i = 0; i < length - 1; i++) { if (i % 2 == 0) { list[i]++; } else { list[i]--; } }} For each array below, indicate what the array's contents would be after the function were called and passed that array as its parameter. use the following as input. {6, 3} {2, 4, 6} {1, 2, 3, 4} {2, 2, 2, 2, 2} {7, 3, 2, 0, 5, 1}arrow_forward#include for(int i = 0; i { int main() for(int j = 0; j< 2; j++) { { int matrix[2][2] = { printf(" %d", matrix[i][j]); } {2,3,}, //rowo printf("\n"); } {5,7}//row1 getch(); }; } printf("\n Resultant \n"); Try to execute, screenshot the resul and try to explain the sequence of the program. Post it in space-ners provided. FRAMEWORK HTPE ADACHE e OrcE outATION roR TECHO A LEarrow_forwardvoid fact(int num) { int k,f=1; for (k=1;k<=num; k++) f=f*k; cout<< f; int main() { int arri[3]={3,2,1} ; for(int i=0;i<3;i++) fact(arri[i]); } 261 O 621 O 7 462arrow_forwardConsider the following function: public void bSearch(int[] A, int value, int start, int end) { if (end value) { return bSearch(A, value, start, mid); } else if (value > A[mid]) { return bSearch(A, value, mid+1, end); } else { return mid; } } The mutation program P' changes the part as shown below. } else if (value > A[mid]) { return bSearch(A, value, mid+2, end); } else { return mid; } A test input is given t1: {A = [2, 3, 5, 7, 10, 11], value = 6, start=0, end=5}. Which statement below best describes the mutant with regards to the test input? O a. t1 resolves mutant P O b. The mutant P' with regards to test input t1 is live.arrow_forward#include using namespace std; int main() (double degree [6] [2]= (30,40,10,70, 20, 30, 60, 70, 30, 10, 10, 85); int buffer=degree[0][0]; for (int i=1;ibuffer) buffer=degree[i][0]; cout<arrow_forwardIn java there must be at least two calls to the function with different arguments and the output must clearly show the task being performed. (ONLY ARRAYS or ARRAYLIST) Develop a function that accepts an array and returns true if the array contains any duplicate values or false if none of the values are repeated. Develop a function that returns true if the elements are in decreasing order and false otherwise. A “peak” is a value in an array that is preceded and followed by a strictly lower value. For example, in the array {2, 12, 9, 8, 5, 7, 3, 9} the values 12 and 7 are peaks. Develop a function that returns the number of peaks in an array of integers. Note that the first element does not have a preceding element and the last element is not followed by anything, so neither the first nor last elements can be peaks. Develop a function that finds the starting index of the longest subsequence of values that is strictly increasing. For example, given the array {12, 3, 7, 5, 9, 8,…arrow_forwardWrite a function void switchEnds(int *array, int size);that is passed the address of the beginning of an array and the size of the array. The function swaps the values in the first and last entries of the array.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_iosRecommended textbooks for you
- 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
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:PEARSONC 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