Ask
your own question, for FREE!
Mathematics
17 Online
OpenStudy (bahrom7893):
Anyone familiar with C++, I have this very easy assignment and I can't get it right.
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (bahrom7893):
OpenStudy (bahrom7893):
I keep getting 4, 3 and 3 as a result
OpenStudy (bahrom7893):
using namespace std;
int main()
{
cout << "Pi approximations: " << endl;
double app1, app2, app3;
app1 = 4;
app2 = 4-4/3+4/5;
app3 = 4-4/3+4/5-4/7+4/9;
cout << app1 << endl;
cout << app2 << endl;
cout << app3 << endl;
system("pause");
return 0;
}
OpenStudy (bahrom7893):
that's my code
OpenStudy (bahrom7893):
ANYONE??? PLEASE HELP!!!
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (anonymous):
i don't know c++ that well but it seems like its truncating even though the number is a double
OpenStudy (anonymous):
also you should probably try the computer science section
OpenStudy (phi):
C++ assumes integer arithmetic if you type in just e.g. 4
replace your constant 4 with 4.0
OpenStudy (bahrom7893):
ohhh lol thanks a lot, just got that suggestion from a computer science section!!!
Can't find your answer?
Make a FREE account and ask your own questions, OR help others and earn volunteer hours!
Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol:
help
4 hours ago
10 Replies
2 Medals
Arriyanalol:
bro how
7 hours ago
2 Replies
3 Medals