Home>Article>Backend Development> What is the usage of if statement?

What is the usage of if statement?

coldplay.xixi
coldplay.xixi Original
2020-10-30 11:08:28 6237browse

The if statement refers to programming languages, including c language, VB, java, assembly language, etc., which are used to determine whether a given condition is met, and decide to perform one of the two operations given based on the result of the determination. , the format is [if (expression) statement 1 [else statement 2]].

What is the usage of if statement?

Usage of if statement:

if statement refers to programming language (including c language, C#, VB, Java, assembly language, etc.) is used to determine whether a given condition is met, and one of the two operations given is executed based on the result of the determination (true or false).

If statement overview

The if statement refers to the programming language (including c language, C, C#, java, VB, assembly language, etc.) used to determine the given Whether certain conditions are met or not, one of the two operations given will be executed based on the result of the judgment (true or false). The return value of if is true or false, which can be stored in a bool variable and occupies one byte.

General form of if statement

The general form of if statement is as follows:

if(表达式)语句1 [else语句2]

The "expression" in the if statement can be a relational expression, Logical expressions, even numerical expressions. Among them, the most intuitive and easiest to understand are relational expressions. The so-called relational expression is an expression that compares two numerical values.

if statement in C language

C language provides 2 forms of if statement:

1, if (expression) statement 1

For example:

if(x>y) printf("%d",x);

2, if (expression)

Statement 1

else

Statement 2

For example:

if(x>y) printf("%d",x); else printf("%d",y);

Related learning recommendations:C video tutorial

The above is the detailed content of What is the usage of if statement?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn