TCS
Company
Programming
Definition
What is the output of the following program?
#include
void main()
{
printf("%d",sizeof(5.2));
}
Read Solution (Total 15)
-
- output : 8
Since 5.2 is double value, no. of bytes allocated to a double value is 8...
Hence it ll print 8... - 10 years agoHelpfull: Yes(23) No(1)
- answer:8
By default compiler consider 5.2 as a double
And We know that size of double is 8.
If we want to define 5.2 as a float we can declare 5.2 as 5.2f - 10 years agoHelpfull: Yes(4) No(0)
- Output is 8.
bcoz 5.2 is a double type...
if there had been sizeof(5.2f) then the answer would have been 4 bytes - 9 years agoHelpfull: Yes(3) No(0)
- by turbo compiler and others also 5.2 will be by default considred as long therefore, size will be 8 .
- 10 years agoHelpfull: Yes(2) No(0)
- 2 as it is int
- 10 years agoHelpfull: Yes(1) No(9)
- 4
sizeof the float is 4 - 10 years agoHelpfull: Yes(1) No(5)
- 5.2 is taken as double type by default so size is 8
- 10 years agoHelpfull: Yes(0) No(0)
- out put:8
The compiler treats it as double.The size of double is 8 bits... so it will print 8 as output. - 10 years agoHelpfull: Yes(0) No(0)
- its a float so answer is 8
- 10 years agoHelpfull: Yes(0) No(0)
- 2 bytes
as %d specifies integer. - 10 years agoHelpfull: Yes(0) No(2)
- ans : 8
5.2 represents the double .so ,double size is 8 - 8 years agoHelpfull: Yes(0) No(0)
- 8
Since every floating point literal is of "double" type. - 7 years agoHelpfull: Yes(0) No(0)
- 8
size of double - 7 years agoHelpfull: Yes(0) No(0)
- this is outpt of 5.2
- 7 years agoHelpfull: Yes(0) No(1)
- it prints 8
- 4 years agoHelpfull: Yes(0) No(0)
TCS Other Question