0
Please how do I write a c++ program that allows my user input double precision floating point values
8 Réponses
+ 1
Nehemiah oseremen , you should use setpricision as below:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double d;
cin >> d;
cout << fixed << setprecision(2);
cout << d << endl;
return 0;
}
your cin statement ask you to provide input value when your code execution reaches that line. on solo learn app as of now, all the input by user should be provided when you start the execution by hitting run button.
+ 1
Double precision is accuracy upto two decimals. I presume that question is asked for 2 decimal accuracy. Double and float does not provide decimal accuracy and setpricision is the one which helps
+ 1
Nehemiah oseremen below code sample might help you:
https://code.sololearn.com/cpaN4tJjP97N/?ref=app
0
double d;
cin >> d;
cout << d;
0
So where do I input this in my program?
0
What does setprecision have to do with the question?
0
Not really......I just need all the values to be double precision
I'm using them to calculate the sum, average, and minimum and maximum of the values inputted.
0
Ketan Lalcheta, your terminology is confused. 'Double precision' is not really about two decimal places.
Read up here:
https://en.m.wikipedia.org/wiki/Double-precision_floating-point_format