Home>Article>Backend Development> How to use do while statement in c language

How to use do while statement in c language

coldplay.xixi
coldplay.xixi Original
2020-08-31 13:23:32 16268browse

How to use the do while statement in C language: The basic structure of do while is [do{ }while();]. If the content in the while statement is true, the while loop will be executed. If it is not true, the while loop will end. .

How to use do while statement in c language

[Related learning recommendations:C language tutorial video]

Use Method of do while statement in c language:

1. First, we define a few variables

int i,a;

i=0;a= 5;

How to use do while statement in c language

2. The basic structure of do while is

do { }while();

where the loop statement is written inside the braces

How to use do while statement in c language

3. If the content in the while statement is true, execute the while loop. If it is not true, end the while loop. For example, write a>i; note the semicolon after while()

How to use do while statement in c language

4. For example, we write i in the loop statement and perform the increment operation of i

How to use do while statement in c language

5. At this time, we write the output statement. Look at the changes in the value of i

How to use do while statement in c language

6. Execute our statement, we will find that the output value of i is 5; the loop ends when the loop in while does not hold.

How to use do while statement in c language

If you want to learn more about programming, please pay attention to thephp trainingcolumn!

The above is the detailed content of How to use do while statement 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