1. Conditional judgment
By default, every line of code that we write in the program will be executed. But most of the time, we want to execute a piece of code when a certain condition is established.
This situation can be done using conditional statements, but we do not study conditional statements for the time being, first look at some more basic knowledge: How to judge a condition is not tenable.
2. True and False
In C language, the condition is called "true", the condition is not established is called "false", therefore, the judgment condition is established, is the judgment condition "true and false".
How to judge True and false? C language rules, any value is true and false, any non-0 value is "true", only 0 is "false". In other words, 108, 18, 4.5, 10.5, etc. are all "true" and 0 are "false".
3. Relationship Comparison
It is often compared in development, such as the size of the cards in the game of landlords. You can compare the size of two values by using the relational operator.
Relational operators result in only 2 of the results: if the condition is true, the result is 1, or "true", and if the condition is not true, the result is 0, or "false".
4. Use note
The precedence of the = =,! = in the relational operator equals,<, <=, >, >=, and the precedence of the former is lower than the latter: 2==3>1
The associative direction of the relational operator is "left to right": 4>3>2
The precedence of the relational operator is less than the arithmetic operator: 3+4>8-2
1#include <stdio.h>2 3 intMain ()4 {5 /*6 int a = ten;7 8 int b = one;9 Ten //condition is set to return 1, really One //conditions are not established on return 0, False A int result = b >= A; - - printf ("%d\n", result); the */ - - //int a = 2>3==1; - //int a = 3+4 > 8-2; + - intA =5!=4+2*7>3==Ten; + Aprintf"%d\n", a); at - return 0; -}
"Learning Notes", "C language" relational operators