operation and flow control of C language
First, the operation part:
type conversion in C language
Forcing type conversionsint b = (int) 10.5 //Double int
Automatic type conversion
int a = 10.6 //Double int
int B = 10.5 + 1.7 //Automatic large conversion to decimal type, loss of precision
Automatic type promotion
int b = 10.5 +10; //INT--double-lift the right 10 to the double type to resolve
double b =3.0/2; //Solve the precision problem of division or double b = (double) 3/2;
1 sizeof (ten); //calculation of bytes/storage space 2 3 sizeof ten; // can be without parentheses 4 5 sizeof (a); // You can use the variable name 6 7 sizeof (double); // computes the number of bytes of type double
Relational operations in C language
Not 0 is true, only 0 is false.
Also called the comparison operation
Commonly used are: > < >= <= = = =!
Logical operations in C language
Logic and condition a && condition B //AB at the same time set up as true
Logic or condition A | | Condition b //AB as long as there is a set up is true
Logical Non! Conditions //True or false false is true
Three-mesh operations in C language
Conditions? Value A: Value b //condition is set to return a, not set to return B
Second, the Process Control part
Process control is divided into sequential structure, selection structure and cyclic structure.
The selection structure in C language
Select Structure IF
if (expression) the first structure
Statement 1;
if (expression) second structure
Statement 1;
Else
Statement 2;
if (expression) third structure
{
Statement 1;
}
If the fourth kind of structure
else if
Else
Select Structure Switch
switch (expression/value)
{
Case value 1;
Statement 1;
Break ; //exit the entire switch statement
Case value 2;
Statement 2;
Break
Defauletl;
Statement 3;
Break
}
Loop structure while
1 while (condition) 2 3 { 45 loop body // is set to execute only once, not set up never execute 67 } 89 dead loop:while (1);
Loop structure Do While
1 Do { 23 // execute one at a time before judging 4 5 } while (conditions);
Loop structure for
1 for (statement 1; condition; statement 2) 2 3 { 45 loop body 67 } 8 9for (,,)
Break and Continue
Break
Exit the entire switch statement or exit the entire loop statement
Continue
End the current loop body and enter the next loop body
loop structure and operations in the C language is a very important part, especially the loop structure, in a lot of places can come in handy, so must be the circular structure study understand, the research is thorough, so as to avoid some small mistakes in the future.
The operation and flow control of the Dark Horse programmer----C language