Multiple choice technology programming languages

7) main() { float me=1.1; double you=1.1; if(me = = you) printf(“I love u”); else printf(“I hate you”); }

  1. I hate you

  2. I love your

  3. error

  4. will not compile

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The line if(me = = you) is problematic. In C, the assignment operator is '=' not ' = '. The 'me = = you' appears to be a typo for 'me == you'. Assuming it means 'me == you': me is float (1.1) and you is double (1.1). Due to floating point representation differences, they may not compare exactly equal. Float and double have different precision. Typically 1.1 as float != 1.1 as double in binary representation. So the condition is false, and 'I hate you' prints. Also note that even if it was 'me == you', the comparison would be false due to precision differences.