/* This program displays the square roots of a sequence of values,
 *    specified by the user on the command line.
 *
 *   Receive: One or more numeric (double) values
 *   Output:  The square roots of the input values
 *******************************************************************/

#include <iostream.h>              // cin, cout, <<, >>
#include <cmath>                   // sqrt()
#include <cstdlib>                 // strtod()

int main(int argc, char * argv[])
{
   if (argc < 2)
   {
      cout << "\n*** Usage: sroot List-of-Positive-Numbers \n\n";
      return 1;
   }

   double inValue;                 // double equivalent of an argument

   for (int i = 1; i < argc; i++)
   {
      inValue = strtod(argv[i], 0);
      if (inValue > 0)
         cout <<"\n--> The square root of " << inValue
              << " is " << sqrt(inValue) << endl;
      else
         cout << "\n*** " << argv[i] << " is not a valid data item;"
              << "\n*** must be numeric and greater than 0.\n"
              << endl;
   }
}

