Use if-else Statement to check double type value - C++ Statement

C++ examples for Statement:if

Description

Use if-else Statement to check double type value

Demo Code

#include <iostream>
#include <cmath>
using namespace std;
int main()//  w ww.  j a v a  2 s.  com
{
   double radius;
   cout << "Please type in the radius: ";
   cin  >> radius;
   if (radius < 0.0)
      cout << "A negative radius is invalid" << endl;
   else
      cout << "The area of this circle is " << 3.1416 * pow(radius,2) << endl;
      return 0;
}

Result


Related Tutorials