Loop structures: Difference between revisions

Content added Content deleted
No edit summary
Line 170: Line 170:
[[Category:C plus plus]]
[[Category:C plus plus]]
=== Run-Time Control Structures ===
=== Run-Time Control Structures ===
:''See [[Loop Structures#C|C]]''

==== for ====
'''Compiler:''' [[GCC]] 3.3.4
#include <iostream>
int main()
{
int i = 1;
// Loops forever:
for(; i == 1;)
std::cout << "Hello, World!\n";
}

====do-while====
'''Compiler:''' [[GCC]] 4.1.2
int main (void) {
int condition = 1;
do {
// Do something
// Don't forget to change the value of condition.
// If it remains nonzero, we'll have an infinite loop.
} while ( condition );
}

[[Category:C plus plus]]

====while====
'''Compiler:''' [[GCC]] 4.1.2
int main (void) {
int condition = 1;
while ( condition ) {
// Do something
// Don't forget to change the value of condition.
// If it remains nonzero, we'll have an infinite loop.
}
}


==[[Forth]]==
==[[Forth]]==