C++ examples for Data Type:float
Calculate the area of a circle of given radius.
#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; }