Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?

0 Answers  


What is scope and lifetime of a variable in c?

0 Answers  


What is the use of header files?

0 Answers  


what is the structure pointer?

0 Answers   Accenture, HCL,


Write a c program to find, no of occurance of a given word in a file. The word is case sensitive.

2 Answers  


int a=2,b=3,c=4; printf("a=%d,b=%d\n",a,b,c); what is the o/p?

6 Answers   Verifone,


Explain the difference between fopen() and freopen().

2 Answers  


3. Program to print all possible substrings. ex: String S St Str Stri Strin String t tr tri trin tring r

3 Answers   Huawei,


Explain threaded binary trees?

0 Answers  


Can i use “int” data type to store the value 32768? Why?

0 Answers  


Explain Linker and Loader

5 Answers  


What is the ANSI C Standard?

0 Answers   Celstream,


Categories