+ 1
what will be the output and why?
#include <iostream> using namespace std; int main() { float x=1.2; double y=1.2; bool res; if(x==y) { res=true; } else { res=false; } cout<<res; return 0; }
2 Answers
+ 1
The answer will be false.
float and double are different datatypes
although the number they store can be the same, the format of the data is different
a float stores the data in 4 bytes
where a double stores the data in 8 bytes
https://code.sololearn.com/cQmk0J2kdl8V