This shows you the differences between two versions of the page.
— |
cpp:control_structures:while [2024/02/16 01:04] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{keywords>wiki library source code example reference}} | ||
+ | ===== while ===== | ||
+ | <code cpp> | ||
+ | #include <iostream> /* including standard library */ | ||
+ | while ( condition == true ) { | ||
+ | do something until condition untrue | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | ===== cpp Sourcecode Example ===== | ||
+ | <code cpp> | ||
+ | |||
+ | #include <iostream> /* including standard library */ | ||
+ | |||
+ | using namespace std; | ||
+ | int main(void) { | ||
+ | int i=0; | ||
+ | |||
+ | while (i <= 99) { | ||
+ | cout << i << endl; | ||
+ | i++; | ||
+ | } | ||
+ | return 0; | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | //output:// | ||
+ | |||
+ | 0 | ||
+ | 1 | ||
+ | 2 | ||
+ | 3 | ||
+ | 4 | ||
+ | 5 | ||
+ | 6 | ||
+ | 7 | ||
+ | ... | ||
+ | up to 99 | ||
+ | |||
+ |