fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int i = 0;
  8.  
  9. cout << "I am going to list numbers now:" << endl;
  10.  
  11. // while loop executes its body while the condition holds
  12. // (careful not to end up in an infinite loop!)
  13.  
  14. while (i<42)
  15. {
  16. cout << i << endl;
  17. i = i + 1;
  18. }
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
I am going to list numbers now:
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41