+ 1

Why "world" is printing in my code

Help me in finding the reason https://code.sololearn.com/czlDsPLgb6hg/?ref=app

10th Sep 2019, 2:11 PM
Prakhar
6 odpowiedzi
+ 3
Print values of both variables like this.. printf("%.20f\n",i); printf("%.20lf",j); You will understand on your own why it is printing World instead of hello..
10th Sep 2019, 2:25 PM
Alaska
Alaska - avatar
+ 4
Because i and j are not equal. When ever you compare two variables of same value and of different data types it results in false. For example you can check by comparing an int and a float.
11th Sep 2019, 12:27 PM
Manoj
Manoj - avatar
+ 3
double has more precision than float. That's why both values differ. Print those two lines as AnonymousGuy said and you get it.
10th Sep 2019, 3:47 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 2
Because these variables have different types and aren't equal to eachother.
10th Sep 2019, 2:19 PM
Krystian Dąbrowski
Krystian Dąbrowski - avatar
+ 2
data types are different. Use same datatypes to compare.
11th Sep 2019, 2:07 AM
RigelStar
RigelStar - avatar
+ 1
Thanks to all of you
11th Sep 2019, 3:15 AM
Prakhar