Study day 5.2

Time:2022-5-19

C language

  1. If — the representative statement and judgment condition of the selection structure

    1. if

    2. If else

    3. if else if else、

    4. int num = 100;
      	int cost = 0;
      	if (num > 200)
      		cost = 1;
      	else if (num > 300)
      		cost = 2;
      	else if (num > 80)
      		cost = 3;
      	else if (num > 70)
      		cost = 4;
      	else
      		cost = 5;
      	printf("tiaoc");
    5. There are expressions after if, which are generally logical expressions or relational expressions. If statements can be used alone. There is no else, but else cannot be used alone

    6. . if statements can be nested. If contains if

    7. Pairing of else and if, pairing of the previous unpaired if