/* 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>
#include <math.h>
#include <stdlib.h>

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

   double
      Value;                // double equivalent of an argument

   for (int i = 1; i < argc; i++)
   {
      Value = strtod(argv[i], 0);

      if (Value > 0)
         cout <<"\n--> The square root of " << Value
              << " is " << sqrt(Value) << "\n";
      else
         cout << "\n*** " << argv[i] << " is not a valid data item;"
              << "\n*** must be numeric and greater than 0.\n";
   }

   return 0;
}
