C Programming :: Variables & Data Types - Discussion
Home > C Programming > Variables & Data Types > MCQs Questions Discussion
33 / 51
What will be output of the following "c" code?
#include<stdio.h>
void main(){
float a=5.2;
if(a==5.2)
printf("Equal");
else if(a<5.2)
printf("Less than");
else
printf("Greater than");
}
#include<stdio.h>
void main(){
float a=5.2;
if(a==5.2)
printf("Equal");
else if(a<5.2)
printf("Less than");
else
printf("Greater than");
}
AEqual
BGreater than
CLess than
DCompilation Error
Answer: Option (Login/Signup)
Show Explanation
5.2 is a double-type constant in C. In C, size of double-type data is 8 bytes while variable 'a' is of float-type. Size of float variable is 4 bytes.
So, double-type constant, i.e, 5.2 is stored in the memory as-
101.00 11001100 11001100 11001100 11001100 11001100 11001101
On the other hand, content of variable 'a' will be stored in the memory as-
101.00110 01100110 01100110
It is clear that variable 'a' is less than the double-type constant 5.2.
Hence, the output is Less than.
Asked In ::
STEP-BY-STEP
5.2 is a double-type constant in C. In C, size of double-type data is 8 bytes while variable 'a' is of float-type. Size of float variable is 4 bytes.
So, double-type constant, i.e, 5.2 is stored in the memory as-
101.00 11001100 11001100 11001100 11001100 11001100 11001101
On the other hand, content of variable 'a' will be stored in the memory as-
101.00110 01100110 01100110
It is clear that variable 'a' is less than the double-type constant 5.2.
Hence, the output is Less than.
Read Full Answer
Report Error
Please Login First Click Here