Example
int
main(
int
argc,
char
* argv[])
{
int
i;
for(i=
0
; i<
10
;i++){
for(i ; i<
5
; i++){
cout <<
"\ni: "
<< i;
}
}
return
0
;
}
Solution
Use different variables for the control of nested loops.
int
main(
int
argc,
char
* argv[])
{
int
i;
int
j;
for(i=
0
; i<
10
;i++){
for(j=
0
; j<
5
; j++){
cout <<
"\ni: "
<< i;
cout <<
"\nj: "
<< j;
}
}
return
0
;
}