EBK C++ PROGRAMMING: PROGRAM DESIGN INC
8th Edition
ISBN: 9781337669085
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 C++ PROGRAMMING: PROGRAM DESIGN INC
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_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_forwardSuppose 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_forward
- Old 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_forwardDo the whole program in C++ & Please kindly share the whole programarrow_forwardd) 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_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_forwardWrite the function splitList that takes the first argument list and splits it into two: a list of all the elements that are less than the head (the second argument), and a list of all the elements that are greater than or equal to the head (the third argument): listElementT splitList(listADT list, listADT* ItList, listADT* geList); Note that the head is returned by the function. a) Write this function as a recursive function. b) Write this function as a nonrecursive function.arrow_forwardAt point in time complete.arrow_forwardplease use python languagearrow_forwardin c++arrow_forwardm = int(temp[1]) IndexError: list index out of range line 3, in <module> m = int(temp[10])IndexError: list index out of range when i ran this test case input: 3 jun3 Jin1 Li2 Kitty2 Josh3 Bob1 Dave2 Jose1 David3 Rob3 Anne3 Ann2 Kevin2 Lara1 ALI3 Xin expected output: Li Dave David ALI Kitty Josh Kevin Lara jun Bob Anne Ann Xinarrow_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