C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7, Problem 7.17E
( What Does This Code Do?) What does the following
- // Ex. 7.17: Ex07_17.cpp
- // What does this program do?
- #include <iostream>
- #include <array>
- Using namespace std:
- Const size_t arraySize {10}:
- Inst whatIsThis (const array
&, size_t); // prototype - Int main ( ) {
- Array
a{1,2,3,4,5,6,7,8,9,10}; - Int result {whatIsThis (a, array Size) };
- Cout << “Result is “ << result << end ] ;
- }
- // What does this function do ?
- Int whatIsThis (const array <int, arraySize>& b, size_t size ) {
- If (size==1) { // base case
- Return b[0];
- }
- Else { // recursive step
- Return b[size-1] + whatIs This(b, size-1);
- }
- }
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
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…
Use Array instead of vectors-
Implement following classes and required member functions in C++ OOP style.
A main function
Introduce Movie object first. Then add several Movie objects along with necessary data ( Date, Title, Genre, category etc ) to array of movies.
Movie class that has functions to add and delete movies.a. Introduce a searchEvent(by category/title/year etc) which will print out all movies of a specified search.
Perform deletion and insertion operations.
Introduce sort movies function by year, title and category and display.
Introduce private members of your choice and use Setter and/or getter functions extract and modify these data members.
Then please make sure you invoke all functions in main function.
Fast answer please
in C++ // praphrase or change this code , while the purpose and output is 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…
Chapter 7 Solutions
C++ How to Program (10th Edition)
Ch. 7 - Exercises 7.6(Fill in the Blanks) Fill in the...Ch. 7 - (True or False) Determine whether each of the...Ch. 7 - (Write C++ Statements) Write C++ statements to...Ch. 7 - (Two-Dimensional array Questions) Consider a...Ch. 7 - (Salesperson Salary Ranges) Use a one-dimensional...Ch. 7 - (One-Dimensional array Questions) Write statements...Ch. 7 - (Find the Errors) Find the error(s) in each of the...Ch. 7 - (Duplicate Elimination with array) Use a...Ch. 7 - Prob. 7.14ECh. 7 - Prob. 7.15E
Ch. 7 - (Dice Rolling) Write a program that simulates...Ch. 7 - ( What Does This Code Do?) What does the following...Ch. 7 - (Craps Game Modification) Modify the program of...Ch. 7 - (Converting vector Example of Section 7.10 to...Ch. 7 - Prob. 7.20ECh. 7 - (Sales Summary) Use a two-dimensional array to...Ch. 7 - (Knight's Tour) One of the more interesting...Ch. 7 - (Knight's Tour: Brute Forty Approaches ) In...Ch. 7 - (Eight Queens) Another puzzler for chess buffs is...Ch. 7 - (Eight Queens: Brute Force Approaches) In this...Ch. 7 - Prob. 7.26ECh. 7 - (The Sieve of Eratosthenes) A prime integer is any...Ch. 7 - Prob. 7.28RECh. 7 - (Eight Queens) Modify the Eight Queens program you...Ch. 7 - (Print an array) Write a recursive function...Ch. 7 - Prob. 7.31RECh. 7 - Prob. 7.32RECh. 7 - (Maze Traversal) The grid of hashes (#) and dots...Ch. 7 - Prob. 7.34RECh. 7 - Making a Difference 7.35 (Polling) The Internet...
Knowledge Booster
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
- Programming Language: C++ Please provide notes for understanding. 7.3: Delete Repeats Write a function called delete_repeats that has a partially filled array ofcharacters as a formal parameter and that deletes all repeated letters fromthe array. Since a partially filled array requires two arguments, the functionwill actually have two formal parameters: an array parameter and a formalparameter of type int that gives the number of array positions used. Whena letter is deleted, the remaining letters are moved forward to fill inthe gap. This will create empty positions at the end of the array so thatless of the array is used. Since the formal parameter is a partially filledarray, a second formal parameter of type int will tell how many arraypositions are filled. This second formal parameter will be a call-by-reference parameter and will be changed to show how much of the array is used after the repeated letters are deleted. For example, consider the following code:char (Links to an…arrow_forward6.3 Find the error in each of the following program segments. Assume int *zPtr; // zPtr will reference array z int *aPtr = NULL; void *sPtr = NULL; int number; int z[5] = {1, 2, 3, 4, 5}; sPtr = z; a) ++zptr; b) // use pointer to get first value of array; assume zPtr is initialized number = zPtr; c) // assign array element 2 (the value 3) to number; assume zPtr is initialized number = *zPtr[2]; d) // print entire array z; assume zPtr is initialized for (size_t i = 0; i <= 5; ++i) { cout << zPtr[i]; } e) // assign the value pointed to by sPtr to number number = *sPtr; f) ++z;arrow_forward30.// programming Write a function void reverse(int a[ ], int size) to reverse the elements in array a, the second parameter size is the number of elements in array a. For example, if the initial values in array a is {5, 3, 2, 0}. After the invocation of function reverse(), the final array values should be {0, 2, 3, 5} In main() function, declares and initializes an integer array a with{5, 3, 2, 0}, call reverse() function, display all elements in final array a. Write the program on paper, take a picture, and upload it as an attachment. Or just type in the program in the answer area. m861144 m861144arrow_forward
- Please Help!!!! write in c++ languagearrow_forward[In C#] Write a class named Sorting with static sort function in order to sort the following array as Pakistan. Call sort function in the main function. char[] p= {‘a’, ‘p’, ‘i’, ‘k’, ‘t’, ‘a’, ‘n’, ‘s’};Output as = pakistanarrow_forwardC++arrow_forward
- C++ Write a function that accepts an array and its size as arguments, creates a new array that is a copy of the argument array, and returns a pointer to the new array. Display the array in main(). The function will work as follows: Accept an array and its size as arguments. Dynamically allocate a new array that is the same size as the argument array. Copy the elements of the argument array to the new array. Return a new pointer to the new array. // This program uses a function to duplicate// an int array of any size.#include <iostream>using namespace std;// Function prototype_________________________________________________int main(){ // Define constants for the array sizes. const int SIZE1 = 5, SIZE2 = 7, SIZE3 = 10; // Define three arrays of different sizes. int array1[SIZE1] = { 100, 200, 300, 400, 500 }; int array2[SIZE2] = { 10, 20, 30, 40, 50, 60, 70 }; int array3[SIZE3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // Define three pointers for the duplicate arrays. int *dup1 =…arrow_forwardii) Write a explicit custom comparator that sorts the array in descending order. Test the custom comparator taking a random array. C++arrow_forwardDon't use vector array .using ifstream and ofstream. C++ programarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended 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 Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
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