0
How to solve this problem?? Say in detail so i can understand..
var x=1; for(i=0; i<=10; i++){ for (j=0; j>=2; j++){ for(k=0; k<5; k++){ x++; } } } document.write(x);
2 Antworten
+ 6
k max value is 5, j is 0 and i is 11
their multiplication is 0 so output will be initial x (1)
when for loops are nested, calculate their max value and and multiply them
+ 5
You have to count how many time each loop will be done.
The one with "i" will be done 11 times.
The one with j will never be done as 0>=2 is false (11*0).
The k one will never be done because of the j one (11*0*5).
So the output is 1