lundi 27 février 2017

Digits after decimal points in printing outputs

I need to do the following computations.

sqrt(abs(pow(a, 2) - pow(b, 2)))
sqrt(abs(pow(a, 2) + pow(b, 2)))

Let a = 4 and b = 5 so the outputs are 3 and 6.40312. Now if I want to print like 3.0 and other one kept as same 6.40312 how can I do that? If I use setprecision() and fixed the outputs are 3.0000and 6.40312. How can I have varible lenght decimal points results with cout?

Aucun commentaire:

Enregistrer un commentaire