当前位置:网站首页>Literacy of C language concept knowledge (supplemented and updated from time to time)

Literacy of C language concept knowledge (supplemented and updated from time to time)

2022-06-22 05:08:00 Jiangxueqian

Program = data structure + Algorithm

Program : A set of instructions that a computer can recognize and execute , Each instruction causes the computer to perform a specific operation . A program consists of one or more source program files . The most fundamental function of a program is to process data , It is also necessary to control the process of data processing .

data structure : A description of the data , Specify which data to use in the program , And the type and organization of the data .

Algorithm : A description of the operation , Steps that require the computer to operate .

Characteristics of efficient algorithms ( Conditions for judging the validity of the algorithm )

  1. Fineness : An algorithm should contain limited operation steps , But not infinite .
  2. deterministic : Every step in the algorithm should be deterministic , It should not be vague 、 Equivocal .
  3. Zero or more inputs : Input refers to the need to obtain necessary information from the outside when executing the algorithm .
  4. There is one or more outputs : The purpose of the algorithm is to solve , Output is solution .
  5. effectiveness : Every step in the algorithm should be able to be effectively executed , And get certain results .

Structured algorithms : The algorithm structure is composed of three basic control structures .

The three basic control structures of a program : Sequential structure 、 Branching structure 、 Loop structure .

Structured programs : A structured algorithm expressed in computer language .

Structured programming method

  1. The top-down
  2. Gradually refine
  3. Modular design
  4. Structured programming



Language

Machine instructions : A binary code that a computer can recognize and accept directly .

machine language : A collection of machine instructions .

assembler : A symbolic language ( assembly language ) Software that converts instructions from to machine instructions .

compiler ( compiler ): A program written in a high-level language ( Source program ) A program that converts to machine instructions ( Target program ) Software for .

compile : The process of generating an object program from a source program using a compiler .

Executable program : The program is compiled and then ( Link editor ) Processing generates an object program that can be executed by a computer .

Program and source program : A program consists of one or more source program files . A source program file consists of one or more functions and other related contents ( Such as instructions 、 Data declaration and definition, etc ) form . A source program file is a compilation unit , When the program is compiled, it is compiled in the unit of source program file , Instead of compiling on a function basis .




function

function : Function is function , Each function is used to implement a specific function , The name of a function should reflect the function it represents . The function is C The main components of the program , yes C A subroutine of a language . The main function is also one of the functions .

The purpose of function declaration : The function declaration is used to put the information about the function ( Function name 、 Function type 、 Number and type of function parameters ) Notify the compiling system , So that in case of a function call , The compiler system can correctly identify the function and check whether the call is legal .

Arguments and formal arguments : On function call , An argument variable passes its value to a formal parameter variable ( Value passed ), Arguments and formal parameters occupy different storage units in memory , After the function call , The parameter storage space is freed . Due to the nature of one-way value transfer , A change in the value of a formal parameter cannot change the value of an argument .




sentence

sentence : Statement is the most basic execution unit of a program , The function of a program is realized by executing a series of statements .

identifier : Some are used to set variables 、 Symbolic Constant name 、 function 、 Data type and other named valid character sequences , In short , An identifier is the name of an object . By letter 、 Numbers and underscores , The first character must be a letter or underscore .

if-else sentence :C The language is only if-else Branch statement , But not if-(else if)-else This form . We usually use else if In essence, it is in else There's one nested in it if .if With the following else At the same level .




data

Constant : While the program is running , A quantity whose value cannot be changed .

Variable : While the program is running , The amount whose value can be changed .

Loop control variable : Control the execution of the loop by changing and judging the value of a variable , Such variables are called loop control variables .

Constant variable : When you define variables , Add a keyword before const, The value of a variable cannot be changed during its existence .

Symbolic constant : Use #define Instructions , Specifies that a constant is represented by a symbolic name , It's called a signed constant . After precompiling , Symbolic constants will all become literal constants .

Global declarations : Data is declared outside of the function .

Global variables : Variables defined and declared outside a function are called global variables . It is valid within the scope of the whole source program file . conventional , The first letter of the global variable name is capitalized . If the global variable is not assigned an initial value, the system will automatically assign a value of 0.

local variable : The variables defined and declared in the function are local variables , Only valid within the scope of a function . If a local variable is not assigned an initial value, an error will be reported .

Scope : If a variable is valid within the scope of a file or function , The scope is called the scope of the variable .

data type : So called type , It is the arrangement of allocating storage units to data , Including the length of the storage unit ( How many bytes ) And the storage form of data , Different types allocate different lengths and storage forms .

Array : A collection of ordered data , Each element in the array belongs to the same data type . The array name represents the address of the first element of the array , Or the starting address of the array .

A character array :C Language has no string type , There are no string variables , Strings are stored in character arrays . The array used to store character data is a character array . Because character data is in integer form (ASCII code ) Deposited , So you can also use integer arrays to store character data , Although it is legal to do so, it will waste storage space .

character string : String is not a variable , It's a constant . stay C Only character variables in language , No string variable .

Structure : A composite data structure composed of different types of data .

Statement and definition : Define the statement that creates the storage space , A declaration that does not require the creation of storage space is called a declaration ( Or quote ). The so-called declaration , Its purpose is to indicate that the variable is a variable that has been defined elsewhere , Just to extend the scope of the variable “ Statement ”.




operation

Operator : Operators represent operations on data objects of various data types .

expression : Operators and operands ( It can be a constant 、 function 、 Variable etc. ) The meaningful combination of forms the expression .

Arithmetic expressions : Use arithmetic operators and parentheses to separate the operands ( Operands ) Connected , Formulas that conform to the syntax rules of the programming language are called arithmetic expressions .

Relationship expression : A formula that connects two numeric values or numeric expressions with relational operators , It's called relational expression . The value of a relational expression is a logical value , There are only two results, namely “ really ” And “ false ”, stay C In the logic operation of language , In numerical terms 1 It means true , In numerical terms 0 On behalf of false .

Logical expression : A formula that connects relational expressions or other logical quantities with logical operators is a logical expression . A logical expression has only two results, namely “ really ” And “ false ”, stay C In the logic operation of language , In numerical terms 1 It means true , In numerical terms 0 On behalf of false .

The left value : An lvalue means that it can appear to the left of the assignment operator , Its value can be changed . Not all forms of data can be used as lvalues , Lvalue should be storage space and can be assigned .

Right value : An expression that can appear to the right of an assignment operator is called an R-value . An lvalue can also appear to the right of the assignment operator , Therefore, all left values can be used as right values .

Relational operators and their precedence

  1. <, <=, >, >= Have the same priority ,== And != Have the same priority . But the first four have a higher priority than the last two .
  2. Relational operators take precedence over arithmetic operators ( +, -, *, /, % ).
  3. Relational operators take precedence over assignment operators ( = ).

Logical operators and their precedence

  1. !( Not ) Greater than &&( And ) Greater than ||( or ).
  2. && and || Below relational operator ,! Higher than arithmetic operators .
原网站

版权声明
本文为[Jiangxueqian]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220503533927.html