#常量一共有四种
##1.字面常量,直接输入输出常量,一般不用。
#include <stdio.h>
int main()
{
1;
31;
return 0;
}
##2.const 修饰的常变量,将变量定义为常量,不能够改变,但是本质还是变量,不能用来定义数组。
const int a = 10;
##3.#define 定义的常量,可以放在任何地方,一般放在头文件后面。
#include <stdio.h>
#define x 100
int main()
{
printf("%d", x);
return 0;
}
##4.枚举常量,定义一个枚举可以作为常量,数值默认为0,1,2…
#include <stdio.h>
enum sex
{
男,
女
};
int main()
{
enum sex s = 男;
printf("%d\n", s);
printf("%d", 女);
return 0;
}