The sizeof Operator in C

The sizeof operator is used to determine the number of bytes required to store a value of a specific data type.

#include <stdio.h>

int main() {
    int result, int_array[10];
    double double_array[10];
    
    printf("size of int = %2d bytes \n", result=sizeof(int));
    printf("size of int_array[10] = %2d bytes \n", result=sizeof(int_array));
    printf("size of float = %2d bytes \n", result=sizeof(float));
    printf("size of double = %2d bytes \n", result=sizeof(double));
    printf("size of double_array[10] = %2d bytes \n", result=sizeof(double_array));
    printf("size of long double = %2d bytes \n", result=sizeof(long double));
    return 0;
}

The output is :

The sizeof operator in C

IDE: Xcode Version 6.1.1

Compiler: Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)

Operating system: OS X Yosemite Version 10.10.1 (64-bit kernel)

Processor: Intel Core 2 Duo (64-bit processor).