while loop
De cppreference.com
[] |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
Excute une boucle .
Original:
Executes a loop.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Utilis lorsque le code doit tre excut plusieurs fois tant qu'une condition est prsent .
Original:
Used where code needs to be executed several times while some condition is present.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Syntaxe
while ( cond_expression ) loop_statement
|
|||||||||
Explication
cond_expression doit tre une expression dont le rsultat est convertible en
bool. Il est value avant chaque excution de loop_statement, qui est excute seulement si le cond_expression value true .Original:
cond_expression shall be an expression, whose result is convertible to
bool. It is evaluated before each execution of loop_statement, which is only executed if the cond_expression evaluates to true.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Si l'excution de la boucle doit tre mis fin un certain moment,
instruction break
peut tre utilis comme terminaison dclaration . Original:
break statement
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
Original:
If the execution of the loop needs to be terminated at some point,
instruction break
can be used as terminating statement. Original:
break statement
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Si l'excution de la boucle doit tre poursuivie la fin de la boucle,
instruction continue
peut tre utilis comme raccourci .Original:
continue statement
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
Original:
If the execution of the loop needs to be continued at the end of the loop body,
instruction continue
can be used as shortcut.Original:
continue statement
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Mots-cls
Exemple
#include <iostream>
int main()
{
int i = 0;
while (i < 10) i++;
std::cout << i << '\n';
int j = 2;
while (j < 9) {
std::cout << j << " ";
j += 2;
}
}
Rsultat :
10
2 4 6 8