解析
第一题:
先输出x,在声明x,会导致compile time error,一定要先声明再使用变量。
第二题:
不赋值,则默认变量为0。
第四题:
//What is the output of this C code?
#include <stdio.h>
int x = 5;
void main()
{
int x = 3;
printf("%d", x);
{
int x = 4;
}
printf("%d", x);
}
注意变量的作用域,int x=4在花括号中,则新的x的作用域仅局限于花括号中,影响不了输出,和第三题有所区别,所以输出3 3.
第六题:
Global varibles 的中文是全局变量,全局变量是external。
第八题:
和之前的一样,先声明,后定义,不然会出现compile time error。