Demonstrates floating point variables - C++ Data Type

C++ examples for Data Type:float

Description

Demonstrates floating point variables

Demo Code

#include <iostream>
using namespace std;
int main()/* ww  w.  j  ava 2s  .c o  m*/
{
   float rad;                           //variable of type float
   const float PI = 3.14159F;           //type const float
   cout << "Enter radius of circle: ";  //prompt
   cin >> rad;                          //get radius
   float area = PI * rad * rad;         //find area
   cout << "Area is " << area << endl;  //display answer
   return 0;
}

Result


Related Tutorials