+ 6

What will be the output and why?

#include <iostream> using namespace std; int main() { float a = 0.1; double b = 0.1; if(a==b){ cout <<"Values are Equal."; }else{ cout<<"These values are not Equal."; } return 0; }

11th Mar 2017, 9:25 AM
Zain Khalid
Zain Khalid - avatar
4 Antworten
+ 2
As the datatypes of the two variables are different, hence the above code will produce "These values are not equal". float store values with only 7 significant digits. On the other hand double allows to store bigger range and 15 digits precision. Both datatypes are all together different datatypes hence values represented in these datatype can't be identical even if both are same.
11th Mar 2017, 9:52 AM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
0
these values are not equal
13th Mar 2017, 9:01 AM
Kaung Htet Kyaw
Kaung Htet Kyaw - avatar
0
these values are not equal
20th Mar 2017, 7:31 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
0
These values are not equal
7th Apr 2017, 9:45 PM
Julio Esparza