Hey, Im writing a money type calculations program, how do I limit the output's number of decimals?
Hey, Im writing a money type calculations program, how do I limit the output's number of decimals?
using printf()'s format specifiers?
try something like
printf("Value: %.2f\n",1.2345);
the .2 specifies the float point precision should be set to 2 digits.
output: Value: 1.23
go here for a list and explaination of format specifiers for printf()
http://www.cplusplus.com/ref/cstdio/printf.html
ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.
Thank you very much.