Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use three conditional judgment sentences in C language

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report