Calculate the area of a circle of given radius. - C++ Data Type

C++ examples for Data Type:float

Description

Calculate the area of a circle of given radius.

Demo Code

#include <iostream>

int main()//from ww w  .j ava2  s  .c  o  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;
}

Result


Related Tutorials