I have a homework problem for C Programming that I can't figure out. Please help! Thanks in advanced!
float f1 = 0.2, f2 = 0.5;
printf("(f1*f1 == 0.1) = %d", f1*f1 == 0.1);
printf("(f1+f1 == 0.07) = %d", f1+f1 == 0.07);
Update:Thanks jacob. wouldn't f1+f1=0.01 though? Making the output 0?
Copyright © 2024 1QUIZZ.COM - All rights reserved.
Answers & Comments
Verified answer
It would print this:
(f1*f1 == 0.1) = 1
printf("(f1+f1 == 0.07) = 0
The == operator evaluates to either true or false, 1 and 0 respectively, so when you print with printf it will print everything inside the brackets plus whatever variable you have. In your case you are testing some things (what f1*f1 is and what f1+f1 is) so you will get the corresponding boolean(true or false).