fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int sum = 0;
  6. for (int i = 2; i <= 100; i += 2) {
  7. sum += i;
  8. }
  9. cout << "The sum of all even numbers between 1 and 100 is: " << sum << endl;
  10.  
  11. return 0;
  12. }
  13.  
Success #stdin #stdout 0.01s 5436KB
stdin
50
stdout
The sum of all even numbers between 1 and 100 is: 2550