牛客网-[编程入门]有容乃大

链接:https://www.nowcoder.com/questionTerminal/4712159bbc15417086d40d6c6ff94fee
来源:牛客网

题目要求:

确定不同整型数据类型在内存中占多大(字节),输出不同整型数据类型在内存中占多大(字节)。

输入描述:

输出描述:

不同整型数据类型在内存中占多大(字节),具体格式详见输出样例,输出样例中的?为不同整型数据类型在内存中占的字节数。输出样例如下:
The size of short is ? bytes.
The size of int is ? bytes.
The size of long is ? bytes.
The size of long long is ? bytes.

代码如下:

#include 
#include 
int main()
{
     
    printf("The size of short is %d bytes.\n",sizeof(short));
    printf("The size of int is %d bytes.\n",sizeof(int));
    printf("The size of long is %d bytes.\n",sizeof(long));
    printf("The size of long long is %d bytes.\n",sizeof(long long));
    return 0;
}

注意事项:
sizeof要和#include 搭配使用。
本题难度为1星。

你可能感兴趣的:(牛客网题集)