Friday 12 April 2013

Operator's tricky Program 8


What will be output of the following program?

#include<stdio.h>
int main(){
    printf("%d %d %d",sizeof(3.14),sizeof(3.14f),sizeof(3.14L));
    return 0;
}

Explanation
Output: 
Turbo C++ 3.0: 8 4 10

Turbo C ++4.5: 8 4 10

Linux GCC: 8 4 12

Visual C++: 8 4 8

Explanation:
3.14f is floating point constant. Its size is 4 byte. 3.14 is double constant (default). Its size is 8 byte. 3.14L is long double constant. Its size is 10 byte. sizeof() operator always return the size of data type which is written inside the(). It is keyword.

No comments:

Post a Comment