C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
bartleby

Videos

Textbook Question
Book Icon
Chapter 6, Problem 7PP

(Numerical) Heron’s formula for the area, A, of a triangle with sides of length a, b, and c is

A = s ( s a ) ( s b ) ( s c )

where

s = ( a + b + c ) 2

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   a n d   [ 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.

Blurred answer
Students have asked these similar questions
(Single Digit) Complete the definition of the following function:singleDigit :: Int -> Int singleDigit takes a positive integer, num, as input and returns a digit between 0 and 9 as the output. The output is computed as follows: sum all the digits in num to obtain a result; if this result is less than 10 then result is the answer; otherwise take the result and apply the same procedure (i.e. sum its digits and compute a result, and so on). Here is a sample run:*Main> singleDigit 37425 3 *Main> singleDigit 9876543 6 Here is how the above answers are computed by hand:singleDigit 37425 => 3+7+4+2+5 = 21 => 2+1 = 3 singleDigit 9876543 => 9+8+7+6+5+4+3 = 42 => 4+2 = 6
(Perfect Numbers) An integer is said to be a perfect number if the sum of its divisors, including 1 (but not the number itself), is equal to the number. For example, 6 is a perfect number, because   6=1+2+3. Write a functionisPerfect that determines whether parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. Print the divisors of each perfect number to confirm that the number is indeed perfect. Challenge the power of your computer by testing numbers much larger than 1000.
(Square of Asterisks) Write a function that displays a solid square of asterisks whose side isspecified in integer parameter side. For example, if side is 4, the function displays:  **** **** **** ****
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
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
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