0

Why "false" executed? Can any one explain it.

#include<iostream> //#include<stdio.h> using namespace std; int main(){ double a=0.1,b=0.2,c=0.3; if(a+b==c) cout<<"true"; else cout<<"false"; }

4th Aug 2021, 11:26 AM
Gaurav Prajapati
Gaurav Prajapati - avatar
2 Réponses
+ 5
Because, a+b != c. So, the else part is executed https://www.sololearn.com/Discuss/2836796/?ref=app
4th Aug 2021, 11:35 AM
Simba
Simba - avatar
+ 4
Gaurav Prajapati , see the attached code and run it, so you can see the difference between the assigned value and the result of the addition. the values are not the same! https://code.sololearn.com/ct8jP8kgBJG1/?ref=app
4th Aug 2021, 4:26 PM
Lothar
Lothar - avatar