#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 |
Can you subtract pointers from each other? Why would you?
How to add two numbers without using semicolon n c????
in one file global variable int i; is declared as static. In another file it is extern int i=100; Is this valid ?
what is the difference between c and c++?
how to write a program which adds two numbers without using semicolon in c
Why is extern used in c?
c program to arrange digits in a no in ascending and descending order
How do I swap bytes?
Given a string write a program to print all alphabetical characters in the order of their occurance first,followed by the sum of the numeric characters then followed by the special characters in the order of their occurance.
1 Answers College School Exams Tests, Wipro,
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
What is the difference between void main() and void main (void) give example programme?
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com