C++   How to Program (Early Objects Version)
C++ How to Program (Early Objects Version)
10th Edition
ISBN: 9780134448824
Author: Paul Deitel; Harvey M. Deitel
Publisher: Pearson Education (US)
bartleby

Videos

Textbook Question
Book Icon
Chapter 7, Problem 7.17E

( What Does This Code Do?) What does the following program do?

  1. // Ex. 7.17: Ex07_17.cpp
  2. // What does this program do?
  3. #include <iostream>
  4. #include <array>
  5. Using namespace std:
  6. Const size_t arraySize {10}:
  7. Inst whatIsThis (const array &, size_t); // prototype
  8. Int main ( ) {
  9. Array a{1,2,3,4,5,6,7,8,9,10};
  10. Int result {whatIsThis (a, array Size) };
  11. Cout << “Result is “ << result << end ] ;
  12. }
  13. // What does this function do ?
  14. Int whatIsThis (const array <int, arraySize>& b, size_t size ) {
  15. If (size==1) { // base case
  16. Return b[0];
  17. }
  18. Else { // recursive step
  19. Return b[size-1] + whatIs This(b, size-1);
  20. }
  21. }

Blurred answer
Students have asked these similar questions
[In c#] Write a class with name Arrays . This class has an array which should be initialized by user.Write a method Sum that should sum even numbers in array and return sum. write a function with name numFind in this class with working logic as to find the mid number of an array. After finding this number calculate its factorial.Write function that should display sum and factorial.Don’t use divide operator
c++ : rewrite this code , to be unique .  In which the output will stay same same.   #include <iostream>#include <stdint.h>using namespace std; class arr{private:    int size_arr;            //To store the size of the array    char *begin;             //Pointer for dynamic allocation of memory    int capacity;            //To store the capacity of the elements in the arraypublic:    arr(int n);              //constructor (default) for creating an array    int insert_arr(char x);  //To insert an element x in the array    int remov_arr(int i);    //To remove an element from position i    void display();    void displayAtPos(int i);//Function to display a character at position i}; arr::arr(int n){    size_arr = n;    begin = new char[size_arr];    capacity = 0;} int arr::insert_arr(const char x){    if(capacity >= size_arr){        cout << "Array Full!" << endl;        return -1;    }    begin[capacity++] = x;            //One element is added, so increment the…
1. a) Fill in the blanks in the code below so that, when the code runs, its output is: 1) got null pointer 2) got illegal array store 3) got illegal class cast public class TestExceptions { public static void main (String [ ] args) { try { } catch (NullPointerException e) { System.out.println ("got null pointer"); } try { } catch (ArrayStoreException e) { System.out.println ("got illegal array store"); }

Chapter 7 Solutions

C++ How to Program (Early Objects Version)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
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
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License