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 betweentwo points on the surface of a sphere. Let (x1, y1) and (x2, y2) be the geographicallatitude and longitude of two points. The great circle distance between the twopoints can be computed using the following formula:d = radius X arccos(sin (x1) X sin(x2) + cos(x1) X cos(x2) X cos(y1 - y2))Write a program that prompts the user to enter the latitude and longitude of twopoints on the earth in degrees and displays its great circle distance. The averageradius of the earth is 6,371.01 km. Note you need to convert the degrees into radiansusing the Math.toRadians method since the Java trigonometric methods useradians. The latitude and longitude degrees in the formula are for north and west.Use negative to indicate south and east degrees. Here is a sample run:   Enter point 1 (latitude and longitude) in degrees: 39.55 −116.25 ↵EnterEnter point 2 (latitude and longitude) in degrees: 41.5 87.37 ↵EnterThe distance between the two points is…
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