fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int multiplyBy2(int x)
  6. {
  7. return 2*x;
  8. }
  9.  
  10. int main()
  11. {
  12. int i, n;
  13.  
  14. // read n from the user
  15.  
  16. cin >> n;
  17.  
  18. // print out the first n even numbers
  19.  
  20. for (i=1; i<=n; i++)
  21. cout << multiplyBy2(i) << endl;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0.02s 2684KB
stdin
5
stdout
2
4
6
8
10