Answers for "C++ float and double Using setprecision() For Floating-Point Numbers"

C++
0

C++ float and double Using setprecision() For Floating-Point Numbers

#include <iomanip>
#include <iostream>

using namespace std;

int main() {
    // Creating a double type variable
    double a = 3.912348239293;

    // Creating a float type variable
    float b = 3.912348239293f;

    // Setting the precision to 12 decimal places
    cout << setprecision(13);

    // Printing the two variables
    cout << "Double Type Number  = " << a << endl;
    cout << "Float Type Number      = " << b << endl;

    return 0;
}
Posted by: Guest on April-09-2022

Code answers related to "C++ float and double Using setprecision() For Floating-Point Numbers"

Browse Popular Code Answers by Language