Azmath
Azmath

Reputation: 9

To understand the logic of c language program

int main()  
{ 
  printf("%d%d%d", sizeof(3.14f), sizeof(3.14l));    
}

OUTPUT --41256

May I know what is the logic behind this output ?

Upvotes: 0

Views: 83

Answers (1)

Anouar Fadili
Anouar Fadili

Reputation: 934

you make an error (3 specifiers and only 2 values).

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

The Output is : "4 16".

"sizeof" of somethings is his size in RAM (memory) in the example 3.14f is a float so it size is 4 bytes for the 3.14l is a long double so it size 16 bytes.

Upvotes: 1

Related Questions