C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2.1, Problem 4E
(Practice) Determine names for functions that do the following:
a. Find the average of a set of numbers.
b. Find the area of a rectangle.
c. Find the minimum value in a set of numbers.
d. Find the density of a steel door.
e. Sort a set of numbers from lowest to highest
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Q27) An approximation for the exponential function can be found using what
is called a Maclaurin series:
x' x? x3
et x 1+
1!
+
+...
2!
3!
Write a program to investigate the value of e and the exp function.
(Fibonacci) The Fibonacci series0, 1, 1, 2, 3, 5, 8, 13, 21, …begins with the terms 0 and 1 and has the property that each succeeding term is the sum of the twopreceding terms. a) Write a nonrecursive function fibonacci(n) that calculates the nth Fibonaccinumber. Use unsigned int for the function’s parameter and unsigned long long int for its returntype. b) Determine the largest Fibonacci number that can be printed on your system.
(Perkovic, Problem 6.31b) Write a function testCraps that accepts a positive integer n as an
input, simulates n games and craps, and returns the fraction of games the player won.
⚫ the testCraps function should not make dice rolls directly, instead...
testCraps function should call the craps function repeatedly and keep track of the results
• if you your craps and testCraps function simulate the game correctly without any extra
rolls, you should be able to hit the results below exactly
1 >>> random.seed(0)
2
>>> testCraps (10000)
3
0.5
4
>>> random.seed(1)
5
>>> testCraps (10000)
6
7
8
0.4921
>>> [(i, random.seed(i), testCraps (100*i)) for i in range(1,10)]
[(1, None, 0.49), (2, None, 0.46), (3, None, 0.47333333333333333), (4, None,
0.5125), (5, None, 0.476), (6, None, 0.47333333333333333), (7, None,
0.4514285714285714), (8, None, 0.48), (9, None, 0.4855555555555556)]
9
>>
Chapter 2 Solutions
C++ for Engineers and Scientists
Ch. 2.1 - (Practice) State whether the following are valid...Ch. 2.1 - Prob. 2ECh. 2.1 - Prob. 3ECh. 2.1 - (Practice) Determine names for functions that do...Ch. 2.1 - (Program) a. Using cout, write a C++ program that...Ch. 2.1 - (Program) a. Write a C++ program to display the...Ch. 2.1 - (Program) a. How many cout statements would you...Ch. 2.1 - (Program) a. Assuming your compiler isn’t case...Ch. 2.1 - (Practice) You’re given the task of wiring and...Ch. 2.1 - (Practice) You’re given the job of preparing a...
Ch. 2.1 - (Practice) You’re a sophomore in college and are...Ch. 2.1 - (Practice) You’re given the job of planting a...Ch. 2.1 - (Practice) You’re responsible for planning and...Ch. 2.1 - (Data processing) a. A national medical testing...Ch. 2.2 - (Debug) a. Will the following program work?...Ch. 2.2 - (Modify) Rewrite the following programs to conform...Ch. 2.2 - (For thought) a. When used in a message, the...Ch. 2.2 - (For thought) a. A token of a computer language is...Ch. 2.3 - (Practice) Determine data types appropriate for...Ch. 2.3 - (Practice) Compile and run Program 2.5.Ch. 2.3 - Prob. 3ECh. 2.3 - (Practice) Show how the name KINGSLEY is stored in...Ch. 2.3 - Prob. 5ECh. 2.3 - Prob. 6ECh. 2.3 - Prob. 7ECh. 2.3 - (For thought) Although you have concentrated on...Ch. 2.3 - (Practice) Although the total number of bytes...Ch. 2.4 - (Practice) For the following correct algebraic...Ch. 2.4 - (Practice) Determine the values of the following...Ch. 2.4 - (Practice) Determine the value of the following...Ch. 2.4 - (Practice) Evaluate the following mixed-mode...Ch. 2.4 - Prob. 5ECh. 2.4 - Prob. 6ECh. 2.4 - Prob. 7ECh. 2.4 - Prob. 8ECh. 2.4 - Prob. 9ECh. 2.4 - (Program) Write a C++ program that displays the...Ch. 2.4 - Prob. 11ECh. 2.5 - (Practice) State whether the following variable...Ch. 2.5 - Prob. 2ECh. 2.5 - (Practice) a. Write a declaration statement to...Ch. 2.5 - Prob. 4ECh. 2.5 - Prob. 5ECh. 2.5 - Prob. 6ECh. 2.5 - Prob. 7ECh. 2.5 - Prob. 8ECh. 2.5 - (Practice) a. Using Figure 2.14 and assuming the...Ch. 2.5 - Prob. 10ECh. 2.5 - Prob. 11ECh. 2.6 - (Modify) a. Modify Program 2.11 to calculate the...Ch. 2.6 - (Modify) a. Modify Program 2.11 to determine the...Ch. 2.6 - Prob. 3ECh. 2.6 - Prob. 4ECh. 2.6 - (Conversion) a. Design, write, compile, and run a...Ch. 2.6 - (Hydraulics) a. Write, compile, and run a C++...Ch. 2.6 - (Thermodynamics) a. Design, write, compile, and...Ch. 2.6 - Prob. 8ECh. 2 - (General math) a. Design, write, compile, and run...Ch. 2 - (General math) a. Design, write, compile, and run...Ch. 2 - (Physics) a. Design, write, compile, and run a C++...Ch. 2 - Prob. 4PPCh. 2 - (Hydraulics) a. Design, write, compile, and run a...Ch. 2 - Prob. 6PPCh. 2 - (Physics) a. The weight of an object on Earth is a...Ch. 2 - (Modify) a. Modify the program you wrote for...Ch. 2 - (Civil eng.) The maximum load that can be placed...Ch. 2 - (Civil eng.) Modify the program written for...Ch. 2 - (Mechanical eng.) The minimum radius required for...
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
- splir + 1).) 7. (Numerical) Heron's formula for the area, A, of a triangle with sides of length a, b, and cie A = vIsts - aXs - b(s - c)] where (a +b+c) Write, test, and execute a function that accepts the values of a, b, and c as parameters from a calling function, and then calculates the values of s and [s(s - a)(s - b)(s - c)]. If this quantity is positive, the function calculates A. If the quantity is negative, a, b, and c do not form a triangle, and the function should set A = -1. The value of A should be returned by the function.arrow_forward(Question 34.).arrow_forward(xiii) Determine all the permutations of the numbers less than or equal to some given number n. For example, if n = 123, then the permutations are: 123 321 231 132 213 312 (xiv) Find a series of five consecutive numbers, the sum of the squares of the first three of which is equal to the sum of the squares of the last two. For example, (– 2)2+ (– 1)2+ 02= 12+ 22 (xv) Limit the checking within 1000, to show all the triad numbers within 10,000. A number is said to be a triad number if the double and triple of the number contain all separate digits with no repetition of any one of them. (xvi) Identify and show the integer values of x, y, and z that satisfy the equation: Z²= X²+ y²arrow_forward
- (Python3) Use the provided cells as a reference to write a for loop that plots the Poisson PDF for a range of λ values from 10 to 100 (by tens) on a single plot.arrow_forward(python) Write a function that will return the first word in a sentence. Call the function first_word. Bonus tasks to handle (1 point each): There can be dots and commas in a string. A string can start with a letter or, for example, a dot or space. The whole text can be represented with one word and that's it. Input: A string. Return: Noting is outputted Return: A string.arrow_forward3. [10 points.] Show that these three statements are equivalent, where a and b are real numbers: (i) a is less than b, (ii) the average of a and b is greater than a (iii) the average of a and b is less than b.arrow_forward
- (C PROGRAMMING ONLY) 5. Making a Kid From Two Personsby CodeChum Admin `The population is slowly decreasing! It's now time to enable these Persons to create their own. But we need to be careful. The overall gender distribution of the Persons should always be maintained (i.e. the Male should be nearly equal as the female) so that gender equality can be easier to maintain. Here is the guide in determining the gender of the newly created Person: If the father is older than the mother, then the child is MaleIf the mother is older than the father, then the child is FemaleIf the father's age is equal to the mother's age and the age is even, then the child is MaleIf the father's age is equal to the mother's age and the age is odd, then the child is Female What are you waiting for, let's settle this problem once and for all! Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age and a character value for…arrow_forward(1 point) The extended Euclidean algorithm computes the gcd of two integers ro and r1 as a linear combination of the inputs. gcd (ro, r1) = s · ro + t · r1 • Here s and t are integers known as the Bezout coefficients. They are not unique. The algorithm works like the standard Euclidean algorithm, except that at each stage the current remainder ri is expressed as a linear combination of the inputs. ri = Siro + tir1. This produces a sequence of numbers ro, r1,.. Suppose that ro = =88 and r1 = 49. , rn-1, n where rn 0 and gcd(0, 1) = rn−1· = . ., rn−1, rn in the blank below. Enter your answer as a comma separated list of Give the sequence ro, r1, · · · numbers. 88,49,39,10,9,1,0 What is GCD(88,49)? 1 What is s? What is t?arrow_forward(python) prov_vac_status() takes a 2-D list (similar to the database) and an integer representing the province ID. This function returns three values; (i) the total number of unvaccinated patients, (i) the total number of partially vaccinated patients, and (i) the total number of fully vaccinated patients hospitalized in this province during the entire period. Note that these numbers include both the icu and the non-icu patients. >>> res1, res2, res3 = prov_vac_status(database, 12) >>> print(f"{res1}, {res2}, {res3}") >>> 194, 14, 118 >>> print(prov_vac_status(database, 35)) >>> (402, 28, 202) >>> print(prov_vac_status(database, 81)) >>> (0, 0, 0)arrow_forward
- (Estimate ) T can be computed using the following series: 1 6*(1 + 4 1 1 + 16 f(n) = + ... 9. 25 Write a function that returns f(n) for a given n and write a test program that dis- plays the following table: f(n) 2 2.73861 4 2.92261 2.99138 3.0273 8 10 3.04936 12 3.06429 14 3.07506 16 3.08319 18 3.08956 20 3.09467arrow_forward1. (Floating-Point Arithmetic). For each of the following numbers,(a) determine whether the number is a 4-digit oating-point number (the number of the FPA4);(b) if yes, write the number in the standard form ±0.d1d2d3d4 × 10n, where d1 is a nonzero digit and n ∈ Z;(c) if no, rst chop and then round the number to a number of the FPA4, written in the standard form:(i) − 0.989067000000001; (ii) − 51.8; (iii) − 900.377050000001; (iv) − 5000.0;(v) − 0.023409; (vi) 2036.0; (vii) 0.01814.arrow_forwardThis is a two questions related to each other. I need help please. Kindly uise wolfram mathematic in writing this code. Thank youarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
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
Boolean Algebra - Digital Logic and Logic Families - Industrial Electronics; Author: Ekeeda;https://www.youtube.com/watch?v=u7XnJos-_Hs;License: Standard YouTube License, CC-BY
Boolean Algebra 1 – The Laws of Boolean Algebra; Author: Computer Science;https://www.youtube.com/watch?v=EPJf4owqwdA;License: Standard Youtube License