学习笔记 c语言第二课

一个c程序的步骤:

定义一个程序目标--设计一个程序--写代码--编译--运行代码--检测和调试程序--维护和修改程序

c语言中的数据类型:

1.char字符数据类型 2.int整型 3.short短整型 4.long长整型 5.long long 6.float浮点型 7.double 双精度浮点型

 

char ch='a'.    char创造一个空间用来储存a,a为字符

float=小数,float 与double float的区别在于double float 的精度要高于float.

sizeof,关键词,操作符,用于计算数据所占用的空间,单位为byte。   sizeof(int)即为计算整型所占的空间。

拓展:计算机中的单位

bit最小的单位,存放一个二进制位

byte字节=8bit

1kb=1024byte

1mb=1024kb....gb....tb....pb

"%d"为格式化,以十进制输出整型,"%f"为输出浮点型,"%lf"为输出double float.

c语言规定,sizeof(long)>=sizeof(int),所以存在等于的情况。

 

计算机语言中,变量为可以改变的量,常量为不可以改变的量。

int age=20

age=age+1

其中int为变量类型,age为变量名称,创建变量时,给变量一个初始值。

下面是一段代码:

cf942e959a9c45dd90811da088d32231.png

定义变量要在使用它之前,一个语句中定义多个类型相同的变量。defined variables before they are used.&

&为地址运算符,后面跟着变量名。&is the address operator,followed by the variable name.

+ addition.   - subtraction.   *. multiplication.    /  division.   %.  remainder

integer division:7/4=1 or 17/5=3

remainder operator:7%4=3 or 17%5=2

 

English:

The steps of a C program:

Define a program objective - Design a program - Write code - Compile - Run code - Test and debug programs - Maintain and modify programs

Data types in C language:
1. char character data type 2. int integer 3. short integer 4. long integer 5. long long 6. float floating-point type 7. double precision floating-point type
Char ch='a '. char creates a space to store a, which is a character
Float=decimal, the difference between float and double float is that the precision of double float is higher than float
sizeof, Keywords, operators, used to calculate the space occupied by data, in bytes. Sizeof (int) is the space occupied by the integer being calculated.
Expansion: Units in Computers
The smallest unit of bits, storing one binary bit
Byte=8-bit
1kb=1024byte
1mb=1024kb.... gb....tb....pb
'% d' is formatted to output integers in decimal, '% f' is output floating-point, and '% lf' is output double float
According to the C language, sizeof (long)>=sizeof (int), so there exists a situation where=.
In computer language, variables are quantities that can be changed, while constants are quantities that cannot be changed.
int age=20
age=age+1
Among them, int is the variable type, age is the variable name, and when creating a variable, give the variable an initial value.

 

部分参照l老师讲课内容,如有错误,还望指出。

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值