0

How to control the number of digits after the decimal point in c++

c++

22nd Aug 2017, 11:28 AM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
13 Respuestas
+ 6
I don't know about C++ but in C we use %.2f for floating values and%.2lf for double values. 2 here represents no. of digits after decimal.Probably there is a function for this in C++
22nd Aug 2017, 11:33 AM
Abhishek Tandon
Abhishek Tandon - avatar
+ 3
can you share your code so we can check where is the problem ?
22nd Aug 2017, 4:46 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar
22nd Aug 2017, 1:43 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar
+ 1
please check my simple example for you https://code.sololearn.com/cw8FZ6U8pNcF/?ref=app be sure you added #include <iomanip>
22nd Aug 2017, 11:52 AM
Melih Melik Sonmez
Melih Melik Sonmez - avatar
+ 1
did you include ? #include <iomanip>
22nd Aug 2017, 12:48 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar
+ 1
yes and it doesn't output any thing for me and the code is correct but with this addition it missed up 😅😅
22nd Aug 2017, 1:28 PM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
+ 1
you put that at the top and you get this error???
22nd Aug 2017, 1:39 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar
0
doesn't work melik at all for me
22nd Aug 2017, 12:42 PM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
0
error:#include nested too deeply
22nd Aug 2017, 1:36 PM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
0
yes
22nd Aug 2017, 1:39 PM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
0
even your code when I put it in my code blocks it gives me that error
22nd Aug 2017, 1:40 PM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
0
still can't solve this problem and It gives me another error redefinition of int main()
22nd Aug 2017, 2:28 PM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
0
even the simplest code when I put #include<iomanip>
22nd Aug 2017, 5:52 PM
Ahmed Mahmoud
Ahmed Mahmoud - avatar