【发布时间】:2020-11-02 00:47:25
【问题描述】:
在我的代码中,我让用户输入下限、上限和步长值。 c2 是下限+步长。摄氏度从下限开始。
for (int x = c2; x <= upperLimit; x + step){
celsius = celsius + step;
cout << celsius;
}
为什么我会收到 for increment 表达式无效的警告?
此外,这个 for 循环现在是无限的,即使它应该在上限处停止。这与警告有关吗?
【问题讨论】:
-
x + step什么都不做。你的意思是x += step或x = x + step。
标签: c++ loops for-loop warnings increment