Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use three conditional judgment sentences in C language

Shulou Source: shulou.com Published: 2022-06-01 07:34:39 10月03日 Update

This article introduces the relevant knowledge of "how to use three conditional judgment sentences in C language". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

If statement

In the if statement, you first judge the value of the expression, and then control the program flow according to the condition of that value. It is true if the value of the expression is not equal to 0; otherwise, it is false. There are three forms of if statement: if,if--else and else if.

If (expression) statement if (expression) {statement block 1;} else {statement block 2;} if (expression 1) statement 1else if (expression 2) statement 2 (expression 2) statement 2. Else if (expression 1) statement n-1else statement nested form if (expression 1) {if (expression 2) {statement block 1 } else {statement block 2;} {else {if (expression 3) {statement block 3;} else {statement block 4;}} conditional operator

The conditional operator can check whether the value of an expression is true or false, and then return one of the other two expressions based on the test result.

Expression 1? Expression 2: expression 3 * * max = (a > b)? aVue b

In the operation, the value of the first expression is checked first. If the value is true, the result value of the second expression is returned; if false, the result value of the third expression is returned.

Example: a > b is true, then max=a; is false, then max-b

Objecy= (flag > = N)? 1PUR 0numma object? Num:num*1.1;LED=mode? ((treadmill_i > (treadmill_i-7))): (treadmill_i

Tags: Statement expression situation condition branch result selection language program test operation two content readability actual more knowledge operator control medium constant Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL NVidia Apple OPPO Reno