Home  >  Article  >  Backend Development  >  Is it correct that a c statement ends with a period?

Is it correct that a c statement ends with a period?

angryTom
angryTomOriginal
2019-11-19 09:22:314815browse

Is it correct that a c statement ends with a period?

C statement ends with a period, right?

The C language does not end with a period, The statement end mark of C language is a semicolon, and it must be a semicolon in English half-width, that is, ';'.

In C language, the semicolon ";" is used to end a statement, just like the daily period ".". (Recommended course: C Language Tutorial )

C program is written in C language and can complete specific A complete set of functional instructions. The basic elements that make up these instructions are called statements. A C program must have a header file and a main program. The main program must start with ‘{’ and end with ‘}’.

Between the two is the statement text. Each line of statements must end with a ';' semicolon. Note that all punctuation must be in English. If you use Chinese punctuation, the program will report an error.

Sometimes there are double slashes '//' in the program. This is a single-line comment character. The statement on the right side only serves as a comment and will not be executed;

In addition, There are multi-line comment characters '/*' and '*/', and the content between these two symbols will not be executed.

Extended knowledge:

C language There is no semicolon after while (expression). If you accidentally add a semicolon, the system will not A compilation error occurs, but the program will continue to perform no-operations, forming an empty loop body. The program following "while (expression);" cannot be executed and the expected effect will not be obtained. For example, adding a semicolon to a while loop in a cumulative summation program will cause an error.

In the do...while loop statement, there is a semicolon after while. Like ordinary statements, this semicolon is used to end the statement. If this semicolon is omitted, the program will not compile and an error will occur.

Therefore, when using the do...while loop statement, don't forget to add a semicolon after while. Even if you forget, the compiler will prompt you and no unforeseen errors will occur.

Note: The semicolon in the do...while statement represents the end of a statement, not the end of the loop body.

The above is the detailed content of Is it correct that a c statement ends with a period?. 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