C Programming - Floating Point Issues - Discussion
Discussion Forum : Floating Point Issues - Find Output of Program (Q.No. 5)
5.
What will be the output of the program?
#include<stdio.h>
#include<math.h>
int main()
{
printf("%d, %d, %d\n", sizeof(3.14f), sizeof(3.14), sizeof(3.14l));
return 0;
}
Answer: Option
Explanation:
sizeof(3.14f) here '3.14f' specifies the float data type. Hence size of float is 4 bytes.
sizeof(3.14) here '3.14' specifies the double data type. Hence size of float is 8 bytes.
sizeof(3.14l) here '3.14l' specifies the long double data type. Hence size of float is 10 bytes.
Note: If you run the above program in Linux platform (GCC Compiler) it will give 4, 8, 12 as output. If you run in Windows platform (TurboC Compiler) it will give 4, 8, 10 as output. Because, C is a machine dependent language.
Discussion:
12 comments Page 2 of 2.
Kamalesh said:
7 years ago
@All.
L or l both are same it has a type long double.
L or l both are same it has a type long double.
Minal Sharma said:
6 years ago
Size of 3.141 represents long double and size of long double is 16 so, the answer would be 4, 8, 16 which is not in the option.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers