Home » C++ Programming » Data Types » Question
  1. What is the output of this program?
    #include 
    #include
    using namespace std;
    int main()
    {
    cout << setprecision(17);
    double n = 0.2;
    cout << n << endl;
    return 0;
    }
    1. 0.20000000000000001
    2. 0.2000000001
    3. 0.200
    4. 2.20000000000000001
    5. None of these
Correct Option: A

The double had to truncate the approximation to its limited memory, which resulted in a number that is not exactly 0.2.



Your comments will be displayed only after manual approval.