Knowledge of C language theory

Source: Internet
Author: User

Reprint: http://www.cnblogs.com/hellokitty1/p/4083928.html

One: Overview of software development
1. The development of programming languages: machine language and assembly language--high-level language.
2. Basic steps and methods of software development: Analyze the problem, build a mathematical model--and determine the data structure and algorithm----Program-----debug program.
3. Basic features of the algorithm: there are 0 or more inputs with one or more outputs for the deterministic validity of the poor.
4. Encoding implementation: Source code compiled source code link.
5. Debugger: Syntax/logic/dev/run-time errors.
6. The program is executed by compiling or interpreting the method.

II: Assembly Language Overview
1. Basic composition: Character Set identifier keyword statement standard function library.
2.C program on-Machine execution procedure general steps: Edit compile link run.

Three: Data is stored in the input and output
1. How the data is represented in the computer: the highest bit in the byte bit to represent the plus, minus sign (known as the sign bit,
A positive number if the sign bit is 0, or negative if the sign bit is 1)
1. Classification of numerical values:
Integer: Short accounts for two bytes;
int accounts for four bytes;
A long account is four bytes;
float: Float accounts for four bytes;
Double accounts for eight bytes;
A long double occupies 12 bytes;
2. Symbolic constants: Form ———— #define Identifier constants (identifiers are typically in uppercase letters).
3. Variable three elements: data type variable name initial value.
4. Format the output function printf:
%d integer;%f decimal;%c single character%s string
5. Format Input function scanf:
&--accessor
6. Regulation of variable name compliance:
The variable name must begin with an alphabetic character (from A to Z, from A to Z);
It can also start with an underscore, but it is not recommended;

Any letter, number, or underscore can be used anywhere in the variable name;

Variable name length is not limited;

Variable names do not allow spaces or non-alphabetic characters, such as + or-;

Variable names cannot be keywords of C language;

Variable names are case-sensitive (the case of letters has meaning, for example mybook is not equivalent to MyBook).


Four. Operator-expression Statements

1. Modulo operator%. Used for integer arithmetic.
2.++x;--x;x++;x--; equality operator (= =);
Inequality operator (! =); logic and (&&);
Logic or (| | );
Logical NON (!)


3. Logical non-operator "!" The highest priority, followed by the arithmetic operator,
Then is the relational operator, again the logical AND operator "&&" and the Logical OR operator "| |",
The lowest value is the assignment operator.
4. Conditional operator: expression 1? (Expression 2): (Expression 3)
5. Classification of statements



Five. Programming of the selection structure

1.if statements
A: Simple if statement
if (expression) {
Statement 1
}
If-else statements

if (expression) {
Statement 1
}else {
Statement 2
}

nested IF statements; (three types)

2.switch statements
Form:
switch (expression) {
case constant Expression 1: statement 1 break;
Case constant Expression 2: statement 2 break;
....
Default: Statement n+1
}
The 3.break statement appears in the switch statement with the Loop statement: Terminates execution of the switch statement or Loop statement where it resides.


Six. Design of cyclic structure

1. Basic concepts of the cycle
A: When the cycle: first judge after the cycle
B: Until the type cycle: first cycle after the judgment.
2. Use the while statement to design a cyclic structure program-the loop of the type.
while (expression) {
Loop Body Statement
}
3. Use the Do-while statement to design the cyclic structure program (the loop body is executed at least once)-until the type loop.
do{
Loop Body Statement
}while (expression);
4. Use the For statement to design a cyclic structure program----------------for the problem of clear cycle times.
for (expression 1; expression 2; expression 3) {
Loop Body Statement

}
Expression 1: Usually the initial value of the loop variable is assigned;
Expression 2: control loop body;
Expression 3: Change the value of the loop variable;
5.continue: Ends the loop and starts the next loop, which can only appear in the loop body of the loop statement.


Seven. Arrays and strings
1. Arrays: arranged in a certain order, with a set of similar types of variables of the same nature.
2. One-dimensional arrays
Form: Data type array name [integer constant expression];
The subscript of an array element starts at 0.
A reference to a one-dimensional array.
Initialization of one-dimensional arrays
Form: Data type array name [integer constant expression]={Initial value 1, initial value 2, ...};
3. Two-dimensional array
Form: Data type array name [integer constant expression 1][integer constant expression 2];
Expression 1: Equivalent to x-axis; expression 2: Equivalent to Y-axis.
A reference to a two-dimensional array.
Initialization of two-dimensional arrays
Form: Data type array name [integer constant expression 1][integer constant expression 2]={initial value data};
4. Character arrays and strings
"Chian" (for string); "' (For character)

Eight. Complex data types
Structure Type:
Declaration of struct type:
struct struct Name {
Data type 1 member name 1;
Data type 2 member name 2;
................
Data type N member name N;
}; (The semicolon here is required)


Nine. Modular programming methods and functions


1. Classification of functions
The functions in C are divided into two categories, one is the standard function provided by the system, also called the library function.
The standard function is defined by the system and can be called directly in the program. The other is the user's own defined function.

2. General format of the function:
function type function name (formal parameter table) {
Description Statement List
List of executable statements
}
3. From the formal perspective of functions, functions are divided into two categories:

parameterless function: When an parameterless function is called, the keynote function does not pass the data to the called function, and the parameterless function can take or return a value without a parameter.

Parameter function: When calling a function, there is data transfer between the keynote function and the called function.
That is, the keynote function can pass data to the used function, and the data in the function can also be brought back for use by the keynote function.



4. The return value of the function is executed by the return statement: return expression;
5. Call to function: Call nested calls recursively

Knowledge of C language theory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.