This is the 11th day of my participation in the August More Text Challenge. For details, see:August is more challenging

  1. variable
  2. The operator
  3. C language statement
  4. An array of
  5. function
  6. Pointer to the
  7. The structure of the body

05 Part Five Variables

Variables are the quantities that can be changed during the running of the program, such as y,z,w, etc.

  • Definition method:

Data type variable 1[, variable 2…] For example:

int a=0;
double b=0.23;
charS = 'A';int *a =0x2323;
Copy the code
  • Initialization: An initial value is given when defined
  • Position of variable definition: usually at the beginning of the function

06 Part Six operator

Arithmetic operator

Assuming variable A = 10 and variable B = 20, then:

An operator

The bitwise and &, bitwise or | and bitwise exclusive or ^ truth table is as follows:

Assignment operator

The assignment operator assigns the value on the right to the variable on the left.

Other operators

In addition, there are relational operators, namely >, ≥, ≤, <,! =, == (what is an equal sign? Two equals again?) In which, the first four take precedence over the last two. In particular, the priority is from high to low. Arithmetic operator > relational operator > assignment operator

Part Seven C language statements

C Statement type

C language is divided into the following five categories:

  • Control statement: such as loop statement while, for, such as conditional statement if, such as branch statement switch.
  • Function call statement: consists of a function call plus a semicolon.
int main(a)
{ int Min(int a,int b){
if(a>b){
returnb; }else{returna; }}}Copy the code
  • Expression statement: Add a semicolon to the end of an expression, such as assignment statement a=a+1.
  • Empty statement: A statement that contains only one semicolon, that is, {}.
  • Compound statement: A sequence of statements enclosed by curly braces {}.

Control statements

If statement:

  • sample

{/ statement to execute if the expression is true /}

  • For example:
main(){
int a=1, b=2;
if(a < b) { ++a; }}
Copy the code
  • Result: if a is less than B, a increases by 1 and becomes 2.

If else statement:

  • sample

If (expression){/ statement that will execute if the expression is true /} else{/ statement that will execute if the expression is false /}

  • For example,
main(){
int a=1, b=2;
if(a < b) { ++a; }
else{a*=4; }}Copy the code
  • Result: if a is less than b, then a increases by 1 and becomes 2; otherwise, a is equal to a times 4.

Goto statement

Break statement:

  • For example:
for(int i=0; i<N; ++i){ 
    if(i == 2) 
        break;
}
Copy the code
  • Result: The loop is terminated directly when I is 2.

The continue statement:

  • For example,
for(int i=0; i<N; ++i){
    if(i == 2)
        continue; }Copy the code
  • Result: When I is 2, this cycle is finished and the next decision is made.

08 Part Eight Array

An array of concepts

  • Int a[100]; // Define an array of 100 integers; • Array: an ordered collection of data elements of the same type;
  • 1. The name common to an array;
  • 2. A variable in a collection;
  • Array dimension: The number of subscripts following the array name;
  • Array element format: array name [subscript];
  • Array definition: < data type > < Array name >[< constant expression >]={< initial value >}

A few points to note

Int a[5]={1,2,3}; //a[0]=1,a[1]=2,a[2]=3,a[3]=0,a[4]=0. Note: Arrays can be defined and initialized, not defined and initialized, as follows:

Array, a two dimensional array data type > < < name > / < 1 > constant expression (< 1 > constant expression) = {< initial value >} : float c [3] [3], then the following elements:

In terms of memory, a two-dimensional array is actually an array of one-dimensional arrays.