How to use floating point literal in C++

1 Answer

0 votes
#include <iostream>

int main() {
    double d1 = 3. * 8/5.;
    double d2 = 3.0 * 8/5.0;

    std::cout << d1 << "\n";
    std::cout << d2 << "\n";
}



/*
run:

4.8
4.8

*/

 



answered Nov 23, 2020 by avibootz
...