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; }

c++

9/5/2019 4:58:00 PM

Sami

2 Answers

New Answer

+1

https://www.sololearn.com/discuss/1955174/?ref=app

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...