
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Solved and run the code in C++ plz
![**Question 3**
**Create a function called reduce**
- Inputs are the starting address of an integer array and the size of the array.
- Dynamically allocate memory for a new array half the size of the inputted array.
- Using a loop place every other element from the inputted array into the newly created array.
- Return the address of the new array.
**Create a function called print**
- Inputs are the starting address of an integer array and the size of the array.
- Using a loop print out all the elements from the inputted array.
**In the main function**
- Create the following integer array `int x[] = {3,5,21,45,16,19};`
- Use the reduce function to reduce the size of the array `x`.
- Use the print function to print out the array `x` and the reduced version of `x`.
- Free up all allocated memory.
Use function prototypes and pointer notation for all arrays.
**Output example**
```
3 5 21 45 16 19
3 21 16
```](https://content.bartleby.com/qna-images/question/4e2a1042-1e85-4015-ae4b-01a486638527/4fd4b44d-8f76-449c-a2b3-0dbdd091b58e/jxlanaf_thumbnail.jpeg)
Transcribed Image Text:**Question 3**
**Create a function called reduce**
- Inputs are the starting address of an integer array and the size of the array.
- Dynamically allocate memory for a new array half the size of the inputted array.
- Using a loop place every other element from the inputted array into the newly created array.
- Return the address of the new array.
**Create a function called print**
- Inputs are the starting address of an integer array and the size of the array.
- Using a loop print out all the elements from the inputted array.
**In the main function**
- Create the following integer array `int x[] = {3,5,21,45,16,19};`
- Use the reduce function to reduce the size of the array `x`.
- Use the print function to print out the array `x` and the reduced version of `x`.
- Free up all allocated memory.
Use function prototypes and pointer notation for all arrays.
**Output example**
```
3 5 21 45 16 19
3 21 16
```
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 2 images

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
- One optional formal parameter of C++ main() is envp. Explain its type and function. Is it helpful to have an addition int parameter (like argc) to specify the number of elements in envp?arrow_forwardCan you please do it in C++ as well?arrow_forwardWhat is meant by operator and function overloading in c++? What are the advantagesarrow_forward
- In order to make advantage of OOP in C++, which header file is required? Which characteristic makes it possible to do open recursion?arrow_forwardShould we use fully qualified or unqualified references for variables and objects in our code? The influence of C's encapsulation problems on C++ and related topics.arrow_forwardExplain what is palindrome and write a code to check whether the given string is palindrome or not? write the code with proper explaination in C++ language.arrow_forward
- How can you print out anything in C++ without cout?arrow_forwardWhen we are talking about c++ and our code, what does encapsulation mean? Please explain in detail thanksarrow_forward이6 ticket_price Complete the following function according to its docstring description. 1 def ticket_price(age: int) -> float: """Return the ticket price for a person with age in years. Seniors 65 and over pay 4.75, kids 12 and under pay 4.25, and everyone else 4 pays 7.50. 6. Precondition: age > e 7 8. >>> ticket_price(7) 9. 4.25 10 >> ticket_price(21) 11 7.5 12 >>> ticket_price(101) 13 4.75 14 History Submitarrow_forward
arrow_back_ios
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