第19391题 单选题
找出关于C++求1~N所有奇数和代码的错误描述

下面的C++代码用于求1~N之间所有奇数之和,其中N为正整数,如果N为奇数,则求和时包括N。有关描述错误的是( )。

1 int N;
2 cout << "请输入正整数:";
3 cin >> N;

5 int i = 1, Sum = 0;

7 while (i <= N){
8  if (i % 2 == 1)
9   Sum += i;
10  i += 1;
11 }

13 cout << i << " " << Sum;
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析