C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
bartleby

Concept explainers

Expert Solution & Answer
Book Icon
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...

Blurred answer
Students have asked these similar questions
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 with below starting function: public static void printFirstAnd Last(ArrayList list) The approach should accomplish the following: Print "no elements" if the list is empty. Print the single element in the list if there is only one. Print the first entry in a list with more than one element, followed by a space, and then the last element.
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]
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education