Concept explainers
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...
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Mindtap Computing, 1 Term (6 Months) Printed Access Card For Malik's C++ Programming: From Problem Analysis To Program Design, 8th (mindtap Course List)
- 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