#include<stdio.h>
int main()
{
printf("Hello world!xxx\n");
printf("Hello 闽江学院!xxx");
return 0;
}
\n:转义符 -- 换行
int 整数类型的一种表达方式
函数名main
函数返还类型 int
数据类型
char -- 字符数据类型 -- char ch = ' a ' ;
%c
整数类型 10 1 2 100 1000 int age = 18; short year = 2021;
short --短整型 %u
int -- 整型 %d printf(“%d”,a)
long -- 长整型 %ld
long long -- 更长的整型 %lld
浮点型 --小数类型
float weight = 52.3;double d = 22.2
float -- 单精度浮点型 %f printf(“%f”,num1)
double -- 双精度浮点型 %lf
sizeof();--计算机数据类型或者变量在计算机空间中所占的大小
所占用空间越大,精度越大,运行速度越慢
int main()
{
char ch ='a';
printf("%c",ch);
printf("%d\n",sizeof(char));//1
printf("%d\n",sizeof(short));//2
printf("%d\n",sizeof(int)) ;//4
printf("%d\n",sizeof(long));//4 sizeof(long)>=sizeof(int)
printf("%d\n",sizeof(long long));//8
printf("%d\n",sizeof(float));//4
printf("%d\n",sizeof(double));//8
return 0;
}
计算机中的单位
bit -- 比特位 1001110101
byte -- 字节 = 8bit 11111111
kb = 1024 byte
mb = 1024 kb
gb = 1024 mb
tb = 1024 gb
pb = 1024 tb
int main()//只能,只允许,只可以有一个main
//局部变量:在大括号内定义的变量称为局部变量--局部变量,只可以在定义所在的大括号中使用
//全局变量:在大括号外定义的变量称为全局变量--全局变量,是可以在所有的函数中使用的--整个项目
//当局部变量和全局变量名字冲突,局部变量优先
当有两个文档时加 extern int
//常数 分四类
1.字面常量
10--int
3.14--float
'a'--char