ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 22 May 2017 My Price 8.00

integer array and an integer value

i am having a struggle with understanding this code properly. Is whatIsThis a proper name for the class on functions of the program or should it be something else. I have not been able to manage to get the program compiled with the source code 

//Ex. 7.18: Ex07_18.cpp

//What does this program do?

#include <iostream>

using std::cout;

using std::endl;

int whatIsThis(int[], int); // This is the function prototype which tells the

// compiler that program would have the definition of

// a function named whatIsThis and would have the parameters

// integer array and an integer value

 

int main()    // main function

 

{

       const int arraySize = 10;  // declares a constant integer variable and initializes it to 10

       int a[arraySize] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };  // declares an array a with size arraySize and initializes it

 

       int result = whatIsThis(a, arraySize);   // it calls the function whatIsThis and passes array a and arraySize values and receives

       // an integer value from the function

 

       cout << "Results is " << result << endl; // prints the result to the console output

       return 0; //indicates successful termination

} // end main

 

// This function recursively finds the sum of the elements in the arrau

int whatIsThis(int b[], int size)

{

       if (size == 1) // base case, at this case it will terminate the recursive function

              return b[0];

       else // recursive step, at this it would call itself again recursively to add the next element into the sum

              return b[size - 1] + whatIsThis(b, size - 1);

} // end function whatIsThis

Answers

(11)
Status NEW Posted 22 May 2017 06:05 AM My Price 8.00

-----------

Attachments

file 1495435928-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)