var x = 1; for (var i = 0; i < 3; i++) { x += 5 * i; } console.log(x);
adanperez1738:
what is the name of this subject and how do you solve or learn it
[email protected] i really want to find out
contact me @ Answers
Answered by
3
the answer is
5*0=0
5*1=5
5*2=10
5*0=0
5*1=5
5*2=10
Answered by
3
Given : x = 1
Iteration 1 :
for( i=0 ; i < 3 ; i++ )
x + = 5 * i ( x = x + 5 * i )
= 1 + = 5 * 0 ( x = 1 + 5 * 0 )
x = 1
Iteration 2 :
for ( i=1 ; i < 3 ; i++ )
x + = 5 * i
= 1 + = 5 * 1 ( x = 1 + 5 * 1 )
x=6
Iteration 3 :
for ( i=2 ; i < 3 ; i++ )
x + = 5 * i
6 + = 5 * 2 ( x = 6 + 5 * 2 )
x=16
When proceeding for next iteration ie; i=3 checks with the for loop for ( i = 3 ; 3 < 3 ; i++ )
It fails the condition in for loop,Thus Exit the Loop and moves to the next line Console.log(x)
Now the Current value for x=16
Hence the output is x = 16.
Similar questions
Hindi,
7 months ago
Social Sciences,
7 months ago
Math,
7 months ago
India Languages,
1 year ago
Biology,
1 year ago
History,
1 year ago
Hindi,
1 year ago
Science,
1 year ago