// Example 4-8: Using continue in a loop.
#include <cmath>
#include <iostream>
#include <istream>
#include <limits>
#include <ostream>

int main()
{
  using std::cin;
  using std::cout;
  while(true) {
    cout << "Enter a number: ";
    double x;
    cin >> x;
    if (cin.eof() || cin.bad())
      // Input error: exit.
      break;
    else if (cin.fail()) {
      // Invalid input: skip the rest of the line.
      cin.clear();
      cin.ignore(std::numeric_limits<int>::max(), '\n');
      continue;
    }
    cout << "sqrt(" << x << ")=" << std::sqrt(x) << std::endl;
  }
}
