Determine Output:
void main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I hate Examveda");
else
printf("I love Examveda");
}
void main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I hate Examveda");
else
printf("I love Examveda");
}
A. I hate Examveda
B. I love Examveda
C. Error
D. None of These
Answer: Option B
Solution(By Examveda Team)
For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
Rule of Thumb: Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ) .
Join The Discussion
Comments ( 1 )
Determine output:
void main()
{
int const *p=5;
printf("%d", ++(*p));
}
A. 6
B. 5
C. Garbage Value
D. Compiler Error
A. mmm nnn aaa
B. mmmm nnnn aaaa
C. Compiler Error
D. None of These
A. I hate Examveda
B. I love Examveda
C. Error
D. None of These
Determine Output:
void main()
{
static int var = 5;
printf("%d ", var--);
if(var)
main();
}
A. 5 5 5 5 5
B. 5 4 3 2 1
C. Infinite Loop
D. None of These
Is void main() even legal for C? Many compilers throw compilation error on encountering this.