0
What's the answer and Why?
#include <iostream> using namespace std; int main() { float a = 1.1; if(a == 1.1) {cout<<"A";} else if(a==1){cout<<"B";} else{cout<<"C";} return 0; }
2 Réponses
+ 4
Hey Vishal Jadhav
Here a=1.1 declared as a "float" and 1.1 is considered "double" by default and Double is greater than float , so output is "C" !
Ex:
float a=1.1 is equal to 1.0999999 (not exact , with 7 precision)
Double a=1.1 is equal to 1.099999999999999999 (with 16 precision)
0
thank you this really helped