Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

here is the code: --------------------------------------------------------------

ID: 3619854 • Letter: H

Question

here is the code:
--------------------------------------------------------------------
#include <iostream>

using namespace std;

int main()
{
float a = 0.6;
float b = 0.4;
float c = 1.0;

if(a + b - c == 0.0){
cout << "TRUE" << endl;
}
else{
cout << "FALSE" << endl;
}

float d = 0.1;
float e = 0.01;
if(d*d == e){
cout << "TRUE2" << endl;
}
else{
cout << "FALSE2" << endl;
}

char qq;
cin >> qq;
}
----------------------------------------------------------------------------------------
when the program is run, both if statements come out false, which is obviously completely wrong. here is the warning message:

warning C4305: 'initializing' : truncation from 'double' to 'float'

the goal is for each statement to come out true.

Explanation / Answer

in the first if statement changing variable type of a,b,c to double prints TRUE.