0

[help] why the output is false??

#include<iostream> using namespace std; int main() { double a = 0.1; double b = 0.2; double c = 0.3; if (a+b == c) cout << "true" << endl; else cout << "false" << endl; system("pause"); return 0; }

5th Sep 2019, 4:58 PM
Sami
Sami - avatar
2 Answers
0
Add iomanip header file...And write this.. int main() { double a=0.1; double b=0.2; double c=0.3; cout<<setprecision(20)<<a+b<<endl; cout<<c; } Execute this code, then you will know the reason behind returning false...
5th Sep 2019, 6:09 PM
Alaska
Alaska - avatar