Answers for "how to get number in decimal in c++"

1

how to get 4 decimal places in c++

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    double d = 122.345;
    cout << fixed << setprecision(4) << d;
}
Posted by: Guest on January-01-2022
-2

c++ get digits of integer

int iNums = 12345;
int iNumsSize = 5;
for (int i=iNumsSize-1; i>=0; i--) {
    int y = pow(10, i);
    int z = iNums/y;
    int x2 = iNums / (y * 10);
    printf("%d-",z - x2*10 );
}
Posted by: Guest on July-22-2020

Code answers related to "how to get number in decimal in c++"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language