C++ Arithmetic Operator Calculate the area of a circle of given radius.

Description

C++ Arithmetic Operator Calculate the area of a circle of given radius.

#include <iostream>

int main()//from  w w w .  j ava  2s.c  om
{
  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