Home > Backend Development > C#.Net Tutorial > What is the statement that ends this loop in C language?

What is the statement that ends this loop in C language?

青灯夜游
Release: 2022-12-30 11:13:30
Original
21221 people have browsed it

The statement that ends this loop in C language is "continue". The control statement continue can only be used in the loop body. Its function is to end this loop and jump to the position where the loop is judged, that is, to restart the next loop.

What is the statement that ends this loop in C language?

The operating environment of this tutorial: windows7 system, c99 version, Dell G3 computer.

In C language, the control statement "continue" is used in the loop body to end this loop and restart the next loop.

In C language, the statements that control the execution sequence mainly include break statement, continue statement, goto statement, exit function and abort function.

  • The break statement is used in a loop statement or switch() statement. When the statement is executed, the loop statement or switch statement is directly ended and the control is transferred to the loop immediately following it. statement or the statement after the switch statement.

  • The continue statement can only be used in the loop body. Its function is to end this loop and jump to the position where the loop is judged, that is, to restart the next loop.

  • The goto statement can be transferred from the conditional statement or loop statement to the label outside the statement for execution.

  • The exit() and abort() functions are used to terminate the execution of the program and return control to the operating system.

Tutorial recommendation: "c language tutorial video"

continue statement

continue statement The function is to skip the remaining statements in the loop body and force entry into the next loop. The continue statement is only used in while and for loops, and is often used together with the if conditional statement to determine whether the condition is true.

Example:

#include <stdio.h>
int main(){
    char c = 0;
    while(c!=&#39;\n&#39;){  //回车键结束循环
        c=getchar();
        if(c==&#39;4&#39; || c==&#39;5&#39;){  //按下的是数字键4或5
            continue;  //跳过当次循环,进入下次循环
        }
        putchar(c);
    }
    return 0;
}
Copy after login

Run result:

0123456789↙
01236789
Copy after login

For more computer programming related knowledge, please visit:Programming Teaching! !

The above is the detailed content of What is the statement that ends this loop in C language?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template