#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
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 |
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 |
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 |
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 |
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 |
How can you determine the maximum value that a numeric variable can hold?
can we store values and addresses in the same array? explain
Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values stored so that value a goes to b,b,to c and c to a
what is the difference between malloc() and calloc() function?
application attempts to perform an operation?
What is a program flowchart and explain how does it help in writing a program?
To what value do nonglobal variables default? 1) auto 2) register 3) static
Is Exception handling possible in c language?
What is meant by int fun const(int a, int b) { .... ... }
Write a program to print all the prime numbers with in the given range
8 Answers ABC, College School Exams Tests, TCS,
What is the memory allocated by the following definition ? int (*x)[10];
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above