EBK MINDTAPV2.0 FOR MALIK'S C++ PROGRAM
8th Edition
ISBN: 9780357425251
Author: Malik
Publisher: VST
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 8, Problem 7SA
Explanation of Solution
The program statements have been explained with in-lined comments.
//declare an array list of 5 elements / components
double list[5];
//the elements of the array list are
//assigned a value of an expression
//for example if i = 3 then
//list[3] = pow(3,3) + 3 /2.0
//= 27 + 1.5 = 28.5
for (int i = 0; i < 5; i++)
list[i] = pow(i, 3) + i / 2.0;
//the output is formatted to show decimal point
//and 2 decimal places after the decimal point
cout << fixed << showpoint << setprecision(2);
//print on a single line with space separated values
//all the elements of the list which are
//0.00 1.50 9.00 28.50 66...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
QUESTION:
NOTE: This assignment is needed to be done in OOP(c++/java), the assignment is a part of course named data structures and algorithm.
A singly linked circular list is a linked list where the last node in the list points to the first node in the list. A circular list does not contain NULL pointers.
A good example of an application where circular linked list should be used is a items in the shopping cart
In online shopping cart, the system must maintain a list of items and must calculate total bill by adding amount of all the items in the cart,
Implement the above scenario using Circular Link List. Do Following:
First create a class Item having id, name, price and quantity provide appropriate methods and then Create Cart/List class which holds an items object to represent total items in cart and next pointer Implement the method to add items in the array, remove an item and display all items.
Now in the main do the following
Insert Items in list
Display all items.
Traverse…
Write a function summax2 : int list -> int = that takes an int
list and returns the sum of the 2 largest integers in it.
1 # summax2 [1;4;6;2;7;8; 3 ; 10 ; 4; - 1] ; ;
2 - :
int = 18
3 # summax2 [1;4];;
4 - :
int = 5
5 # summax2 [1]; ;
6 - :
int - 1
7 # summax2 []; ;
int = 0
Write a function oddfirst : int list -> int list = that takes a
int list and returns the same list, but where all odd numbers come before the
even numbers.
1 # oddfirst [4;2;7;3;1;0; 9;3;6;-1;0;3];;
: int list -
2 -
[7; 3; 1; 9; 3; -1; 3; 4; 2; 0; 6; 0]
3 # oddfirst [1;0;0;4;6;1; 2;100; -7;4; -9]; ;
int list = [1; 1; -7; -9; 0; 0; 4; 6; 2; 100; 4]
Chapter 8 Solutions
EBK MINDTAPV2.0 FOR MALIK'S C++ PROGRAM
Ch. 8 - Mark the following statements as true or false. A...Ch. 8 - Consider the following declaration: (1,2) double...Ch. 8 - Identify error(s), if any, in the following array...Ch. 8 - Determine whether the following array declarations...Ch. 8 - Prob. 5SACh. 8 - Write C+ + statement(s) to do the following: (1,...Ch. 8 - Prob. 7SACh. 8 - Prob. 8SACh. 8 - Prob. 9SACh. 8 - Prob. 10SA
Ch. 8 - Prob. 11SACh. 8 - Correct the following code so that it correctly...Ch. 8 - Prob. 13SACh. 8 - Suppose that points is an array of 10 components...Ch. 8 - Determine whether the following array declarations...Ch. 8 - Prob. 17SACh. 8 - Prob. 19SACh. 8 - Prob. 1PECh. 8 - Prob. 2PECh. 8 - Write a C+ + function, lastLargestIndex that takes...Ch. 8 - Write a program that reads a file consisting of...Ch. 8 - Prob. 6PECh. 8 - Write a program that allows the user to enter the...Ch. 8 - Write a program that uses a two-dimensional array...Ch. 8 - Prob. 12PECh. 8 - Write a program to calculate students average test...
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
- void listEmployees (void) { for (int i=0; i 10000. Make a guess about why the comparison function takes 2 struct Employee parameters (as opposed to struct Employee *) **arrow_forwardAbout initial programming in python: Create a function that receives as parameters a list of 4 elements [name,[phone(s)], email, instagram] and a phone number:• If the phone number is in the list, it must be removed.• If not, no updates will be made. Note: phone(s) is within another list. Your function should only return a Boolean value, indicating whether the change was made or not. To find out if the function did the phone deletion correctly, you should check the contents of the list with the contact details you used to test your function after executing it. In the image is the model of parameters, in this case the function must exclude from the list of 4 elements the indicated number '44322456' and return "True".arrow_forwardcomplete the following function. // It is the same as observeCounter except that f has a parameter of type List[Counter] not Counter. // f will insist that the List[Counter] has length 3. // You must return a List[Int] not an Int. // The first element of the result List[Int] must correspond to the number of times that increment/decrement were called on the first element of type List[Counter], similarly for the second and third elements. def observeCounterList (f : List[Counter] => Unit) : List[Int] = { // TODO: Provide definition here. List (-1, -1, -1) }arrow_forward
- Suppose a node of a doubly linked list is defined as follows: struct Node{ int data; struct Node* next; struct Node* prev; }; Write the function definition of the function deleteElement as presented below. This function deletes a node at position n from a doubly linked list. struct Node* deleteElement(struct Node* head, int n){ //write the function definition }arrow_forwardOld MathJax webview Old MathJax webview In Java Some methods of the singly linked list listed below can be implemented efficiently (in different respects) (as opposed to an array or a doubly linked list), others not necessarily which are they and why? b. Implement a function to add an element before the first element. c. Implement a function to add an item after the last one element. d. Implement a function to output an element of the list. e. Implement a function to output the entire list. f. Implement a function to output the number of elements. G. Implement a function to delete an item. H. Implement a function to clear the entire list. I. Implement functionality to search for one or more students by first name, last name, matriculation number or course of study. J. Implement functionality to sort the records of the student, matriculation number and course according to two self-selected sorting methods.arrow_forward5. The following function indexCounter aims to find and return all the indices of the element x in a list L. if x is not in the list L, return an empty list. However, the implementation has a flaw, so that many times it will return error message. Can you fix the flaw? def indexCounter(L, x): indexList [] startIndex = 0 while startIndex < len(L): indexList.append (L.index (x, startIndex)) startIndex = L.index (x, startIndex) + 1 return indexListarrow_forward
- In c++arrow_forwardWrite a function that accepts two lists as it's only arguments. The function should return a new list containing all the elements of the two list arguments. For example, if the function was passed the lists [1, 2, 3] and [4, 5, 6], it would return a new list containing [1, 2, 3, 4, 5, 6]arrow_forwardDo the whole program in C++ & Please kindly share the whole programarrow_forward
- d) What is the output of the statement? listElement (list, 6): when int list{6j-f23,14.3,-6,36,85;: and the function listElement is: void listElement (int x{ ], int Z) int i: for (i= 0; i< Z; 1++) | xfil=x{Z-i-1/-powli.2.0); cout<arrow_forward-Python3-arrow_forwardint list[3]; for (int i = 0; i < 3; i++) { list[i] = 2 * i + 6; if (i % 2 == 0) list[i] = list[i] - 3; } for (int i = 0; i < 3; i++) cout<arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_iosRecommended 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 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:PEARSONC 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