0

What the complier don't show the ans as 3.15 why it show answer in 8 bit

https://code.sololearn.com/cQ3lporhJXC7/?ref=app

2nd Aug 2018, 4:18 PM
Ranjeet
Ranjeet - avatar
9 odpowiedzi
+ 2
yes Jamie , correct... .2f is what it is required... My bad... setprecision is for cout.
2nd Aug 2018, 4:53 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
try: printf("%g\n", PI);
2nd Aug 2018, 6:15 PM
MO ELomari
MO ELomari - avatar
0
Because you are using float data type , answer will be 3.150000. If you use int data type it will be 3. Hope this helps ☺️☺️.
2nd Aug 2018, 4:30 PM
Meet Mehta
Meet Mehta - avatar
0
but meet i also want exponential part and that is 15 thats why i use float data type
2nd Aug 2018, 4:39 PM
Ranjeet
Ranjeet - avatar
0
you need to use setprecision from iomanip header
2nd Aug 2018, 4:46 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
As Jamie said use .2 to print upto two decimal points. Result => 3.15 Use .3 to print upto 3 decimal points and so on.
2nd Aug 2018, 4:54 PM
Meet Mehta
Meet Mehta - avatar
0
it depends on what you encode on the system
2nd Aug 2018, 7:22 PM
MAVEN
MAVEN - avatar