0
Number of digits after dot in c++ using printf
In this code , i can print MY NUMBER with 2 numbers of digits after decimal point . MY NUMBER is 1.72627827... Code : printf( "%0.2f" , 1.72627827); ........... Now I want print MY NUMBER with N numbers of digits after decimal point . N is giveen by user with cin . How can i do that ?
3 ответов
+ 2
int N;
cin >> N;
printf("%.*f", N, 1.72627827);
+ 1
Thanks ... it works !
But what does it mean ?
"%.*f"
+ 1
http://www.cplusplus.com/reference/cstdio/printf/
All about printf you need to know!