In C language, the colon (:) represents a statement block and is used to group related statements. It is also used in conditional statements to separate different cases, in loop statements to separate conditions and loop bodies, in enumeration declarations to separate constants and integer values, and in goto statements to identify program locations.
The purpose and representation of colon: in C language
In C language, colon (:) is used to represent Multiple directly related statements. It is a statement delimiter that allows writing a series of interrelated statements, called a statement block, on a single line.
Representation method
To represent a colon, in C language, just use a single character colon (:). The colon must be followed by a newline character or other statement.
Purpose
Colon is mainly used for the following purposes:
Examples
Here are some code examples using colons:
<code class="c">// 语句块 int sum = 0; for (int i = 0; i < 10; i++) { sum += i; } // 条件语句 if (age >= 18) { printf("您已成年。\n"); } else { printf("您未成年。\n"); } // 循环语句 for (int i = 0; i < 10; i++) { printf("%d\n", i); }</code>
Note:
The above is the detailed content of In C language: what does it mean and how to express it. For more information, please follow other related articles on the PHP Chinese website!