Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use functions cpp. (Main.cpp is used for reference) Output must be: 88,92,6 100,

ID: 3723601 • Letter: U

Question

Use functions cpp. (Main.cpp is used for reference)
Output must be: 88,92,6 100,104,18 kUCCS 1 09HummelSpring201 8/chapter/6/section/22 za Cloud9 Engineering Overview @ Calc "Barkers Barbershop ry array element 6.22 HW11-02: adding a constant to every array element Given an array A of N integers, write a function addo(A N, c) that adds c to every element of A. This is a void function e. the function does not return a value but instead simply ends in returnç The main) function is written for you your job is to write the adde function Start by reviewing the code for 'main.opp' which is visble in the editor pane -note that this code is read-only (you cannot that the main) program inputs a sequence of integers from the keyboard, stores those values into an array, inputs another value c, and then calls the function addc to update the array Above the editor pane youll see the text Ourrent file main.cpp, with a little drop-down arrow to the right. Click the drop-down and select functions cpp Then to avoid a bug in some web browsers please immediately click the Ink 'Load defauilt template.: You only noed to do this once, the first time you view the file implement the function. To test your workin Develop mode, supply a sequence of integers endng in Q, followed by an additional integer c For example, the following input denotes the sequence 88 92.6, to which the value 12 will be added 92 12 The output from the programis the original sequence of integers, followed by the updated sequencer 08, 92,6 100,104,18 When you are ready to submit for testing, switch to Submit mode and submit for grading You have unlimited submissions TMIY6221:HW11-02 adding a constant to every amay element 0/100 File is marked as reed only Current fler main.cpp - void.dk(int A(], intk, Srt ch 12 int mainc

Explanation / Answer

Hello, I have a solution for you. Implemented everything as per the requirements.

The required code for the method addc() is as follows:

/*method to add a value c to all the elements in an array A

of length N */

void addc(int A[], int N, int c){

            /*looping through all the elements*/

            for(int i=0;i<N;i++){

                        /*adding c to the current element*/

                        A[i]=A[i]+c;

            }

            return;

}

Following is the completed functions.cpp file.

#include<iostream>

#include<string>

#include<cmath>

using namespace std;

/*method to add a value c to all the elements in an array A

of length N */

void addc(int A[], int N, int c){

            /*looping through all the elements*/

            for(int i=0;i<N;i++){

                        /*adding c to the current element*/

                        A[i]=A[i]+c;

            }

            return;

}

/*method to output an array (no changes made) */

void output(int A[],int N){

            for(int i=0;i<N;i=i+1){

                        cout<<A[i];

                        if(i!=N-1){

                                    cout<<",";

                        }

            }

            cout<<endl;

            return;

}

If you have any doubts, feel free to ask, Thanks

/*OUTPUT*/

88

92

6

0

12

88,92,6

100,104,18