Precision-function-in-C++ .

In this session i have discuss precision function in C++ .

The precision() function is used to define how many digit you want to display from decimal point . It is a member function .

Precision() syntax


Where d is number of digit .

Example : Write a program that demonstrate the precision function .

    using namespace std;
    int main()
          double x=2.11111;
          cout<<"Without spcified precision\n";
          cout<<"After spcified precision\n";
          return 0;
    OUTPUT : Without specified precision
             After specified precision

The above program we have specify 3 digits but it will display only two digits after decimal point . It is always display less than one to specified digit .

Welcome to AndroidATPoint.

back image                     next image