Programming in C
Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
Question
Book Icon
Chapter 7, Problem 8E
Program Plan Intro

Program Plan:

  • Include required header files
  • Give the function prototype
  • Define the main function
    • Declare the variables “a”, “b”, “c”.
    • Get three numbers from the user.
    • Calculate the value of “res”.
    • Check whether the value of “res” less than “0”.
      • Print the statement.
    • Otherwise, it enters into the else case if the condition fails.
      • Declare the variables “x1” and “x2”.
      • Call the function “squareRoot()” for “x1”.
      • Call the function “squareRoot()” for “x2”.
      • Print the square roots value
      • Return the value “0”.
  • Definition for the function “absoluteValue(float x)”
    • Check “x” is less than “0”.
    • Assign “-x” to x“.
    • Return the value of “x”.
  • Definition for the function “squareRoot(float x)”
    • Declare the “epsilon” as “float”.
      • Declare the variable “guess” as “float”.
        • Call the function “absoluteValue()”.
          • Compute the value of guess.
        • Return the value of guess.

Blurred answer
Students have asked these similar questions
38. The geometric mean g of n numbers x; is defined as the nth root of the product of x;: g=Vx1x2X3•…Xn (This is useful, for example, in finding the average rate of return for an investment which is something you'd do in engineering economics). If an investment returns 15% the first year, 50% the second, and 30% the third year, the average rate of return would be (1.15*1.50*1.30)") Compute this.
Computer Science This is an introductory exercise to the manipulation of random variables with Python as a language for scientific computing and numerical computation. You have: f(x) = Ae-0.1x)° 4 x*, 0
The great circle distance is the distance between two points on the surface of a sphere. Let (x1, y1) and (x2, y2) be the geographical latitude and longitude of two points. The great circle distance between the two points can be computed using the following formula: d = radius * arccos(sin(x 1) * sin(x 2) + cos(x 1) * cos(x 2) * cos(y1 - y2)) Write a program that prompts the user to enter the latitude and longitude of two points on the earth in degrees and displays its great circle distance. The average earth radius is 6,371.01 km. Note that you need to convert the degrees into radians using the math.radians function since the Python trigonometric functions use radians. The latitude and longitude degrees in the formula are for north and west. Use negative to indicate south and east degrees.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning