What is the usage of while loop?

hzc
Release: 2023-03-01 16:36:01
Original
12928 people have browsed it

What is the usage of while loop?

#What is the usage of while loop?

while is a basic loop mode of computers. When the condition is met, it enters the loop. After entering the loop, when the condition is not met, it exits the loop. The general expression of the while statement is: while (expression) {loop body}.

The syntax format is:

Java

while(<条件>) {<语句;>}
do {<语句;>} while(<条件>);
二者的区别是do-while最少会被执行一次。
循环中可以使用continue结束当前循环,回到循环开始处开始下一次循环。也可以用break跳出整个循环。
Copy after login

PHP

while 循环是 php 中最简单的循环类型。它和 C 语言中的 while 表现得一样。语法如下:
while(expr){
statement
}
Copy after login

javascript

JavaScript中while循环的语法如下:
while (<条件>) {需执行的代码 };
do {需执行的代码 } while (<条件>);
Copy after login

c

do <语句> while(<条件>);
while(<条件>) <语句>;
Copy after login

C

while(<条件>) <语句>;
do <语句> while(<条件>);
Copy after login

Recommended tutorial: "php tutorial

The above is the detailed content of What is the usage of while loop?. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!