C language basic knowledge sorting and help understanding (Part 1)

C language basic knowledge sorting and help understanding - 1

1. Basic data types

Data Type Overview Diagram
1. The basic data types are divided into integer type, real type and character type
2. Identifiers can only be composed of underscores, numbers 0~9 and uppercase and lowercase letters, and the first character of the variable name must be a letter or an underscore "_" (not is a number), system keywords cannot be used.
3. Integers starting with 0 are octal integers. Note that only numbers from 0 to 7 cannot appear, and numbers starting with 0X are all hexadecimal, where a means 10, and F means 15.
4. The exponential form of the real constant: 1.23×10 to the fifth power ==> 1.23e5 5.
'5' is different from 5: '5' goes to the ASCII code table to find the corresponding value, which is the real value
6. Turn free character:insert image description here

2. Operators and expressions

Pay attention to the precedence and combination direction of various operators: assignment sign = is typical from right to left, multiplication sign * and division sign / are typical left to right.
From https://www.mianfeiwendang.com/doc/9c8d69d7e10c2455e616b739

Picture from https://www.mianfeiwendang.com/doc/9c8d69d7e10c2455e616b739

3. Expression

insert image description here
1. Arithmetic expression: An expression is a combination of constants, variables, functions and operators.
`int main()
{ int a = 1; int b = 1;

int i, j, k;
i = a + b;
j = a % 2 / 1;
k = a / b;//这四行均为算式表达式

return 0;

}`
2. Relational expressions: the formulas connected by relational operators and other relational expressions are called relational expressions

int main()
{
    
    
	int a = 1; 
	int b = 2;
	int c = 3;
	int d = 4;// 下面这些关系表达式的结果为:

	//a + b > c - d  结果 : 1
    //a > 3 / 2  结果:0
    //'a' + 1 < 'c' 结果 : 1  字符参与运算时,比较的是其ASCII码的值*/
    //a + 1 == b  结果 : 1
    //a > b > > C  结果 : 0  先计算a>b的结果为0,再计算0>c的结果为0*/
	return 0;
}

3. Assignment expression: The assignment operator is =, and its function is to assign the value of the expression or constant on the right side of the assignment operator to the variable on the left side. It should be noted that the value of the assignment expression is the value of the assigned variable. The value of the assignment expression can also be assigned to other variables.

4. Logical expressions: expressions connected by logical operators are called logical expressions

int main()
{
    
    
	int a,b,c;
	
	//a < b&& c;
	//a==b||c;   均为逻辑表达式
	return 0;
}

4. Conditional expression: We call the expression composed of conditional operators a conditional expression, and its general form is: expression 1? Expression 2: Expression 3;
students who have learned Java can clearly see that this is the ternary operator in Java. If expression 1 is true, the result is expression 2; if it is false, the result is expression 3
insert image description here
The corresponding conclusion can also be obtained through the example I gave.

Then this article will be summarized until this time. I will continue to summarize the corresponding basic knowledge points. Thank you.

Guess you like

Origin blog.csdn.net/qq_74415153/article/details/131213474