C++ How to Program (10th Edition)
C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
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 this exercise, please do not include and use string class. The function is using only array notation and manipulation.- string functions such as strlen is not allowed.- it should not have multiple return statements in the same function- there should be no global variable.- the function should not traverse the arrays more than once (e.g. looping through the array once only) A C++ PROGRAM named "isTheLastNumberTheMax" that accepts an array of integers and its size. It will return true if the last number in the array is the maximum number in that array and false otherwise. In addition, it also returns another boolean to indicate whether this list contains more than one maximum value.For example, if this is called with the array of {10, 20, 30, 40, 50}, it will return true and falseIf this is called with the array of {50, 10, 20, 30, 40, 50}, it will return true and true. A C++ PROGRAM named "changeCase" that takes an array of characters terminating by NULL character (C-string) and…
- in this exercise, please do not include and use string class. The function is using only array notation and manipulation.- string functions such as strlen is not allowed.- it should not have multiple return statements in the same function- there should be no global variable.- the function should not traverse the arrays more than once (e.g. looping through the array once only) A C++ PROGRAM named "changeCase" that takes an array of characters terminating by NULL character (C-string) and a boolean flag of toUpper. If the toUpper flag is true, it will go through the array and convert all lowercase characters to uppercase. Otherwise, it will convert all uppercase to lowercase. For example, if the array is {'H', 'e', 'l', 'l', 'o', '\0'} and the flag is true, then the array will become{'H', 'E', 'L', 'L', 'O', '\0'}. And if the flag is false, the array will become{'h', 'e', 'l', 'l', 'o', '\0'}
2) For each of the following, write C++ statements that perform the specified task.a) Declare a built-in array of type unsigned int called values with five elements, andinitialize the elements to the even integers from 2 to 10.b) Declare a pointer vPtr that points to a variable of type unsigned int.c) Write two separate statements that assign the starting address of array values to pointervariable vPtr.d) Use a for statement to print the elements of array values using pointer/offset notation.e) Refer to the fifth element of values using pointer subscript notation.f) Assume that unsigned integers are stored in two bytes and that the starting address of thearray is at location 1002500 in memory.• If vPtr points to the first element of array values, then what address is referenced byvPtr + 3? (manually calculate)• What value is stored at that location?
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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
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