I'm a student who reads books and teaches himself.
With a book
using namespace std;
int main() { int sum = 0;
for (int i = 1;i <= 10;++i)
{
if (5 == i)
continue;
sum += i;
}
cout << "The current value of i=" << i<< "\n";
cout << "sum from 1 to 4, 6 to 10 =" << sum << "\n";
return 0;
} After writing it and putting it into action, The i in the cout part does not become the i defined and keeps getting errors. I defined i in for() but why is the defined i not input in the cout part?
c++
http://soen.kr/lecture/ccpp/cpp1/7-3-2.htm
Please refer to it
In this code, because i is a variable declared in for, the variable is not available at the end of the for statement.
For more information, google 'variable scope'~
© 2024 OneMinuteCode. All rights reserved.