Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 5, Problem 9P

The area of an arbitrary triangle can be computed using the formula area=s(s–a)(s–b)(s–c)

where a, b, and c are the lengths of the sides, and s is the semiperimeter. s=(a+b+c)/2

Write a void function that computes the area and perimeter (not the semiperimeter) of a triangle based on the length of the sides. The function should use five parameters—three value parameters that provide the lengths of the edges and two reference parameters that store the computed area and perimeter. Make your function robust. Note that not all combinations of a, b, and c produce a triangle. Your function should produce correct results for legal data and reasonable results for illegal combinations.

Blurred answer
Students have asked these similar questions
To convert between Celsius and Fahrenheit, the following formula is used, where C = Celsius temperature and F = Fahrenheit temperature: C = 5/9 * (F-32) Write a C++ temperature conversion program which does the following: Write a function called toCelsuis which takes a Fahrenheit temperature as a parameter, and returns the equivalent Celsius temperature: float toCelsius(float) Demonstrate that your function works by writing a main() function that prints out a conversion table.  It should have Fahrenheit values 60, 61, 62, ... through 80 (21 temperatures in total) and should also have the corresponding Celsius temperatures that your function calculated.  So your output should look something like this (with 21 temperature conversions total, I used ... to save space here for most of them): Welcome to the temperature table!F      C60    15.661     16.1...    ...80     26.7     If you like: you can add this line in your function to make floating point output fixed, make sure you…
The area of an arbitrary triangle can be computed using the formulaarea = √(s(s–a)(s–b)(s–c))where the square root is applied to the entire product  and where a, b, and c are the lengths of the sides, and s is thesemiperimeter  of the triangle given by the formula:s = (a + b + c)/2 Write a void function named  triangle  that computes the area and perimeter (as well as the semiperimeter (which will be used to compute the area)of a triangle based  on the length of the sides. The function should use five parameters and may call other functions.Make your function robust. Note that not all combinations of a, b, and c produce a triangle. Your function should produce correct resultsfor legal data and reasonable results for illegal combinations. Include in your submission a driver that repeatedly reads in 3 positive numbers thatare the sides of a triangle, and each time print out the sides and the area and perimeter calculated by the triangle function. Your program  shouldterminate when the…
In physics, an object that is in motion is said to have kinetic energy. The followingformula can be used to determine a moving object's kinetic energy:KE =112 mv 2The variables in the formula are as follows:• KE is the kinetic energy in joules,• m is the object's mass in kilograms,• and v is the object's velocity in meters per second.Write a function named ki net i cEnergy that accepts an object's mass (in kilograms ) andvelocity (in meters per second) as arguments . The function should return the amount ofkinetic energy that the object has. Demonstrate the function by calling it in a programthat asks the user to enter values for mass and velocity.

Chapter 5 Solutions

Problem Solving with C++ (10th Edition)

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
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
functions in c programming | categories of function |; Author: Education 4U;https://www.youtube.com/watch?v=puIK6kHcuqA;License: Standard YouTube License, CC-BY