c++实验1-100偶数的和
时间: 2024-05-14 21:16:32 浏览: 68
下面是实现1-100偶数的和的C++代码:
```c++
#include <iostream>
using namespace std;
int main() {
int sum = 0;
for(int i=2; i<=100; i+=2) {
sum += i;
}
cout << "1-100偶数的和为:" << sum << endl;
return 0;
}
```
运行结果为:
```
1-100偶数的和为:2550
```
阅读全文