C++ example of float data type

Objectives :

  • float datatype1
    with float types you can represent numbers like 2.5 and 2.145789. Float can also be represented with E notation (3.45E6 means 3.45 106 ) where 6 is tan exponent.

Code

//varfloat2.cpp
#include <iostream>
int main()
{
float longvalue;
longvalue = 10.12456 / 3.568;
cout << longvalue << "\n";
longvalue = 10.123 / 3.568;
cout << longvalue;
longvalue = 10.12e6 / 3.568;
cout << longvalue;
return 0;
}