Here I present some C programs that, at first glance would appear to be really simple and straight forward. However, the output turns out to be quite different from what you expected(which, as we all know, is quite irritating). Read the explanation to reduce the irritation.
ALSO READ:(RECOMMENDED)
- SOME ANNOYING C PROGRAMS-PART II (FREQUENTLY ASKED QUESTION MUST READ)
- SOME ANNOYING C PROGRAMS-PART III (FREQUENTLY ASKED QUESTION MUST READ)
- main() {
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}
Answer:
I hate U
Explanation:
For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
FULL DOCUMENT IS HERE SO DOUBLE CLICK TO GET THIS PDF
Nice !!! A great help!!!
ReplyDeleteFor ques no.-6
ReplyDeleteCan you elaborate this line of solution- "For the second printf a+1 increases in the third dimension thus points to value at 114"
That how it comes to 114 and not to 106??
Sorry, because still not got the logic completely.
ReplyDeleteHere, in above comment u hv selected 102 as base address and not 100. Why??
And if possible kindly also state the basic formula which u used.
hey ,i have updated the answer it should be 112 as base address is 100,so the next address after a+1 should be 112 as 100 + 3*2.Sorry my bad.
ReplyDeleteIf still you didn't got the logic just drop me a mail on freakyfresher@gmail.com & we can discuss it further .
Ohk!! thanks....got d logic
ReplyDelete