SOURCE FILE: functionUser.cpp



/*
    This is a program that show things a programmer can do with the 
    'built-in' function double sqrt(double).

    Other built-in functions: 
       in cmath
       double pow(double, double), 
       double fabs(double), double ceil(double), 
       double floor(double)
 
       in cstdlib
       int abs(int), long labs(long),
       void srand(void), int rand(void)
*/

#include <iostream>
#include <cmath>

using namespace std ;

int main (void)
{
   double x=1.0, y=2.1, z=3.2 ;

   cout.setf(ios::fixed) ;
   cout.setf(ios::showpoint) ;
   cout.precision(4) ;
   
   cout << endl ;

         /* The argument to a function can be a constant */

   cout << "The square root of 2 is about: " 
        << sqrt (2.0) << endl << endl ;

         /* The argument to a function can be a variable */

   cout << "The square root of " << z << " is about: " 
        << sqrt (z) << endl << endl;

         /* Basically any expression that makes sense can be the
            argument of a built-in function */

   cout << "The square root of " << z*z + 2*x - 3*y 
        << " is about " << sqrt (z*z + 2*x - 3*y) << endl << endl ;

         /* A function call is an expression and can be used anywhere
            an expression of its type can be used - like on the right
            hand side of an assignment statement or, for a numerical
            type, a summand, multiplicand, numerator (dividend), or
            denominator (divisor).  You can also put a function call
            where you would put an expression in a cout statement. */

   x = sqrt (x+2.3*z) ;
   z = 15+4*y/sqrt(31+x) ;
         
   cout << "The values of x, y, and z are now about: "
        << x << ", " << y << ", and " << z << ".\n\n" ;

   return 0;
}