sizeof() operators in C

    sizeof operator

    sizeof() operator is used to evaluate the size of data type, variable or constant.
    Example :
    int main()
    {
    int x,y;
    float k;
    char ch;
    double d;
    x=sizeof(float); // sizeof returns 4 and assigned to x
    x=sizeof(char); // sizeof returns 1 and assigned to x
    x=sizeof(int); // sizeof returns 4 and assigned to x
    x=sizeof(double); // sizeof returns 8 and assigned to x
    x=sizeof(d); // sizeof returns 8 and assigned to x
    x=sizeof(k); // sizeof returns 4 and assigned to x
    x=sizeof(ch); // sizeof returns 1 and assigned to x
    x=sizeof(y); // sizeof returns 4 and assigned to x
    x=sizeof(45); // sizeof returns 4 and assigned to x
    x=sizeof(23.67); // sizeof returns 8 and assigned to x
    x=sizeof(‘a’); // sizeof returns 4 and assigned to x
    return(0);
    }

No comments:

Post a Comment

Featured Post

Core and Advance Python

                      Language Fundamentals