fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int i;
  8.  
  9. // simple for loop
  10.  
  11. cout << "first loop" << endl;
  12.  
  13. for (i = 0; i < 6; i++)
  14. {
  15. cout << i << endl;
  16. }
  17.  
  18. // second loop does the same thing as the first one
  19. // but with a while loop
  20.  
  21. cout << "second loop" << endl;
  22.  
  23. i = 0;
  24. while (i<6)
  25. {
  26. cout << i << endl;
  27. i++;
  28. }
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
first loop
0
1
2
3
4
5
second loop
0
1
2
3
4
5