QUIZ 65

What is the output ?

int main()
{
float a=5.55, b=5.50;
if(a=b)
printf(“A is equal to B”);
else 
printf(“A is not equal to B”);
return 0;
 
}
a) A is equal to B
b) A is not equal to B
c) Floats cannot be used in if and switch statements
d) Error
Answer : (a)
Explanation :
Since, assignment operator returns 1 on assignment of value of b to a and conditional statement will evaluate to non-zero value i.e. a, so, if block will always be printed with this condition.

Leave a Reply

Your email address will not be published. Required fields are marked *