Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

How to make a float precise in C++.Help please

$
0
0

Suppose, I declared a float variable p; float p;

now ,I want to take input for p; Such as someone typed 12.123123 for p; But when I'm working in program I want to make p only 2 decimal precised......... Like 12.12 and then do calculation on it.......... Now I need help for 2 things....... How I can just cut off the value like 4.789 to 4.78 And how to make it precise like 4.789 to 4.79 (as the third decimal digit is more than 5). How can I change float precision in these two ways in C and C++.... I ll appreciate any help.thanks....:-)


Viewing all articles
Browse latest Browse all 39796

Trending Articles