变量(variable)

其他数据类型在程序运行期间可能会改变或被赋值,这些称为变量(variable)。

常量(constant)

有些数据类型在程序使用之前已经预先设定好了,在整个程序的运行过程中没有变化,这些称为常量(constant)。

命名规范

共性规则

示例:

  1. /*把年龄转换为天数*/
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. int main(void)
  5. {
  6. int age = 0; //变量
  7. int result = 0;
  8. const int DAYS = 365; //常量
  9. scanf("%d", &age);
  10. result = age * DAYS;
  11. printf("%d\n", result);
  12. system("pause");
  13. }

注:常量的常量名通常用大写表示