1、程序的注释
单行注释://
多行注释:/-------/
2、变量的定义与使用
数据类型 变量名=值
3、常量的定义与使用
1)#define 常量名 常量值
2)将变量修饰为常量:const 数据类型 常量名 = 常量值
代码演示:
1)
#include <iostream>
#include <string.h>
using namespace std;
#define p 3
int main()
{
cout << p<< endl;
return 0;
}
输出为:
3
Process returned 0 (0x0) execution time : 0.851 s
Press any key to continue.
2)
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
const int n=2;
//n=4;如果这样写就会报错,显示左侧是不可修改的值
cout << n<< endl;
return 0;
}
输出:
2
4、关键字
注意:在给变量或常量取名字时,不要使用关键字,避免产生歧义。
5、标识符的命名规则
不能是关键字
由数字、字母、下划线组成,数字不能打头
区分大小写