Home  >  Article  >  Backend Development  >  What are the values ​​of relational expressions and logical expressions in C language

What are the values ​​of relational expressions and logical expressions in C language

hzc
hzcOriginal
2020-06-17 15:59:2916630browse

What are the values ​​of relational expressions and logical expressions in C language

#What are the values ​​of relational expressions and logical expressions in C language?

The values ​​​​of relational expressions and logical expressions are Boolean: true or false (true or false), that is, 0 or 1, but the C language does not have a Boolean type, 0 is false, non-0 That is true.

Logical operations are also called Boolean operations. Boole used mathematical methods to study logical problems and successfully established logical calculus. He expressed judgments in terms of equations and viewed reasoning as transformations of equations. The effectiveness of this transformation does not depend on people's interpretation of the symbols, but only on the combination rules of the symbols. This logic theory is often called Boolean algebra.

In the 1930s, logical algebra was applied to circuit systems. Subsequently, due to the development of electronic technology and computers, various complex large systems appeared, and their transformation laws also obeyed the laws revealed by Boolean.

Introduction

1. Logical expressions in C language

Use logical operators to convert relational expressions or logical A meaningful expression that connects quantities is called a logical expression. The value of a logical expression is a logical value, that is, "true" or "false". When the C language compilation system gives the result of a logical operation, it uses the number 1 to represent "true" and the number 0 to represent "false". However, when judging whether a quantity is "true", it uses 0 to represent "false" and non-0. means "true".

2. You can assign the operation result (0 or 1) of a logical expression to an integer variable or a character variable.

Note

Since floating point numbers cannot be represented very accurately in computers, when judging whether two floating point numbers are the same, the relational operator "equal to" (==) is usually not used. Instead, it is implemented using the interval judgment method.

Recommended tutorial: "c Language"

The above is the detailed content of What are the values ​​of relational expressions and logical expressions in C language. 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