C++ float type Calculate the area of a circle of given radius.

Description

C++ float type Calculate the area of a circle of given radius.

#include <iostream>

int main()/*w  w w.  j a  v  a  2s.co  m*/
{
  const float pi  = 3.14159f;

  float radius {};
  float areaOfCircle {};

  std::cout << "It assumes that the value of pi is " << pi << "." << std::endl;

  std::cout << "Please enter the radius: ";
  std::cin >> radius;

  areaOfCircle = pi * radius * radius;

  std::cout << "\nThe area of the circle is " 
            << areaOfCircle << " square units." << std::endl;
}



PreviousNext

Related