#include<stdio.h>
#include<conio.h>
void main()
{
float a;
clrscr();
a=0.5;
if(a==0.5)
printf("yes");
else
printf("no");
getch();
}

Answers were Sorted based on User's Feedback



#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a=..

Answer / abhishek singh

yes in output when a=0.5;
but when a=0.4 or 0.6
it no in output

Is This Answer Correct ?    19 Yes 5 No

#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a=..

Answer / ak

yes

Is This Answer Correct ?    6 Yes 0 No

#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a=..

Answer / ravi kant singh

Answer is it will print no.....because you can not compare two floating point number upto precision 

Is This Answer Correct ?    3 Yes 2 No

#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a=..

Answer / ankita sharma

Answer will be yes. we can compare two floating point numbers. as a is having value 0.5 and when it is compared with 0.5 so 1st printf would get executed which is inside if statement. so we would get answer as "yes" on the console window as output.

Is This Answer Correct ?    1 Yes 0 No

#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a=..

Answer / maniac

yes

Is This Answer Correct ?    1 Yes 1 No

#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a=..

Answer / rajan12233

yes

Is This Answer Correct ?    0 Yes 0 No

#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a=..

Answer / sandeep

output is no beacause the default datatype of a floatingpoint value is "double",and doubles are always bigger than floats
so in above a is "float" where 0.5 is double

Is This Answer Correct ?    0 Yes 0 No

#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a=..

Answer / sandeep

HI froends this is sandeep,
Coming to the question :
First of all we should know that in c language:
integers by default are treated as int,
and numbers with decimal point as double.
so int the ques tion "a is float",but "0.5 is double by default" and "double > float by default"
so "a==0.5" turns out to be false,
so else statement will be executed


output:no

Is This Answer Correct ?    0 Yes 0 No

#include<stdio.h> #include<conio.h> void main() { float a; clrscr(); a=0.5; if(a=..

Answer / syam kumar

output is no

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C Interview Questions

How can I convert a number to a string?

0 Answers  


consider the following C code main() { int i=3,x; while(i>0) { x=func(i); i--; } int func(int n) { static sum=0; sum=sum+n; return(sum); } the final value of x is

4 Answers   TCS,


marge linklist

0 Answers   HCL,


Write the control statements in C language

0 Answers   Atos Origin,


Write a program in c to input a 5 digit number and print it in words.

11 Answers  






Why is c still so popular?

0 Answers  


write a program to reverse the words in the sentence.NOTE:not reverse the entire string but just the occurance of each word

1 Answers   Sienna Ecad, Wipro,


c program to print a name without using semicolon

9 Answers   TCS, Wipro,


main() { unsigned int k = 987 , i = 0; char trans[10]; do { trans[i++] =(char) (k%16 > 9 ? k%16 - 10 + 'a' : '\0' ); } while(k /= 16); printf("%s\n", trans); }

4 Answers   Vector,


What is an auto variable in c?

0 Answers  


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

0 Answers  


Write a program for deleting duplicate elements in an array

3 Answers   Subex,


Categories