0

How to get precision in C++?

Im trying to the get the precision to be to the 0.01 but seriously do not know what to do... Im using array by the way

25th Nov 2016, 2:54 PM
Karl Cruz
Karl Cruz - avatar
2 Answers
+ 4
An example would better. Anyway for precision use setprecision function like float x,y,z; x = 11; y = 7; z = x/y; cout<<setprecision(3)<<z<<endl; output: 1.57 Remember this is not a full code, rest of code you have to write yourself. I am just showing a way. You have to include iomanip header file.
25th Nov 2016, 3:19 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
0
Thanks!. Helped a lot in the code I was doing.
25th Nov 2016, 10:09 PM
Karl Cruz
Karl Cruz - avatar