fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int i;
  8.  
  9. cout << "I am going to list numbers now:" << endl;
  10.  
  11. // for loop allows us to initialize variable,
  12. // specify the condition, and also the way the
  13. // variable changes in each iteration of the loop
  14.  
  15. for (i=1; i<10; i=i+3)
  16. cout << i << endl;
  17.  
  18. cout << "The loop was terminated with i = " << i << endl;
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
I am going to list numbers now:
1
4
7
The loop was terminated with i = 10