76 951
Assignments Done
Successfully Done
In June 2019

Answer to Question #25078 in C++ for Dave

Question #25078
I am trying to make a program that will find pi to an imputed specificity.

excerpt that's not working:

cout << "\n OK, so how many values of Pi do you want?\n";
cin >> valuecount;
cout << fixed << setprecision(valuecount) << 22/7 << endl;

If i input 4, i get 1 digit, or "3", instead of "3.141"

everything is already defined at the top:
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <iomanip>
Expert's answer
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <iomanip>

using namespace std;

int main()
cout<<"How many values of PI do you want ?\n";

int valuesCount;

//the problem was that you divide integer values but not double (use 22.0 instead of 22)

cin.get(); //suspend console
cin.get(); //suspend console

return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions