int main(){
float f=8.0;
if(f==8.0)
printf("good");
else
printf("bad");
}
what is the answere and explain it?

Answers were Sorted based on User's Feedback



int main(){ float f=8.0; if(f==8.0) printf("good"); else printf("bad"); } ..

Answer / pratima

BAD

Is This Answer Correct ?    10 Yes 6 No

int main(){ float f=8.0; if(f==8.0) printf("good"); else printf("bad"); } ..

Answer / c++ coder

Answer is "bad"
reason being, that when 8.0 is stored into the float
variable , it is never stored exactly as 8.0 because of
precision. Thus the comparsion will never evaluate to true.
It is always recommended not to do float, double
comparsions like this. :)

Is This Answer Correct ?    2 Yes 0 No

int main(){ float f=8.0; if(f==8.0) printf("good"); else printf("bad"); } ..

Answer / jayaraj.s

good is the result. because we declare and compare the same
value in the program.so alwaye if condition is true. we no
need to put else condition for these type of comparisions.

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More C Interview Questions

Is an array parameter is always "by reference" ?

1 Answers  


What is indirection? How many levels of pointers can you have?

0 Answers   Aspire, Infogain,


hi, which software companys will take,if d candidate's % is jst 55%?

0 Answers  


how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?

0 Answers   Gopaljee, TCS,


What is the -> in c?

0 Answers  






what is the difference between 123 and 0123 in c?

0 Answers  


what is the use of call back function in c?tell me with example

2 Answers   Bosch,


why we wont use '&' sing in aceesing the string using scanf

0 Answers   HCL,


write a programming in c language, 1 3 5 7 9 11

2 Answers   NIIT,


what will be the output of this program main() { int i=1; while (i<=10); { i++; } }

11 Answers  


What do you understand by normalization of pointers?

0 Answers  


Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates

3 Answers  


Categories