We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
You have two choices. The first is to use #include<iomanip> in order to implement setprecision()to modify the number of digits displayed after the decimal and showpoint to ensure that the decimal is physically shown in your output.
The second is to make use of scanf() and printf(). Using std::cout for something like this is more convoluted because the problem is asking for a specific amount of places in the read out. Scan takes the entire value and print will print the entire value without minimizing it for the stream.
This is a prime example of why C is closer to the machine(circuit, hardware, etc) than C++ is. But at the same time C++ "arguably" allows more direct manipulation of your data.
Basic Data Types
You are viewing a single comment's thread. Return to all comments →
You have two choices. The first is to use
#include<iomanip>
in order to implementsetprecision()
to modify the number of digits displayed after the decimal andshowpoint
to ensure that the decimal is physically shown in your output.The second is to make use of
scanf()
andprintf()
. Usingstd::cout
for something like this is more convoluted because the problem is asking for a specific amount of places in the read out. Scan takes the entire value and print will print the entire value without minimizing it for the stream.This is a prime example of why C is closer to the machine(circuit, hardware, etc) than C++ is. But at the same time C++ "arguably" allows more direct manipulation of your data.
Hope this explanation helps. Happy coding