0
I have some confusion in understanding the programming of for loop having multiple initialization...
help me!!!
3 ответов
+ 2
could you paste some code so we can help you?
+ 1
Describe your problem so I can help you.
0
This code works for only one type.
#include <iostream>
int main() {
for (int i=0, j=9; i < 10 && j > 0; i++, j--)
std::cout << i << ", " << j << std::endl;
}
If you need different types, you can initialize them before the loop
#include <iostream>
int main() {
double x = 10.0;
for (int i=0; i < 10; i++, x-=0.1)
std::cout << i << ", " << x << std::endl;
}