+ 1

what is the output for the below code?

#include<stdio.h> int main() { float a=1.1; double b=1.1; if(a==b) { printf("equal"); } else { printf("not equal"); } return 0; }

21st Sep 2020, 8:10 AM
Anusha
Anusha - avatar
3 Respuestas
+ 3
Not equal but i like that they will be equal they are not in the some data type.
21st Sep 2020, 9:31 AM
HBhZ_C
HBhZ_C - avatar
+ 3
Equal
21st Sep 2020, 2:37 PM
Gabriel Caldeira Bicalho
Gabriel Caldeira Bicalho - avatar
+ 1
Not equal.. Because you are comparing with float with higher type double. And in memory representation decimal values are stored slightly less or more decimal value on convertion into binary as ex 1.1 (is double value) to float 1.1 as 1.10000000012 or 1.10000089989 like these, there exists a slight difference in decimal point so those not comes to equal..
21st Sep 2020, 10:00 PM
Jayakrishna 🇮🇳