113k views
1 vote
PLS HELP <3 Type the correct answer in the box. Use numerals instead of words. If necessary, use / for the fraction bar.

var a = 0;

var b = 1;

var c

for(i = 1; I <= 5; i++)

{

C = a +b;

a = b;

b = c;

}

document. write(c);

The output of the document. write statement is ____?

1 Answer

5 votes

Answer:

The output of the document. write statement is

Step-by-step explanation:

Initially:
a = 0 and
b = 1

The iteration is repeated 5 times and the calculation is as follows:

First iteration:


c = a + b =0 + 1 = 1:=>
c = 1


a = b:=>
a= 1


b = c:=>
b = 1

Second iteration:


c = a + b =1 + 1 = 2:=>
c = 2


a = b:=>
a= 1


b = c:=>
b = 2

Third iteration:


c = a + b =1 + 2= 3:=>
c = 3


a = b:=>
a= 2


b = c:=>
b = 3

Fourth iteration:


c = a + b =2 + 3= 5:=>
c = 5


a = b:=>
a= 3


b = c:=>
b = 5

Fifth iteration:


c = a + b =3 + 5= 8:=>
c = 8


a = b:=>
a= 5


b = c:=>
b = 8

End of iteration

document. write(c) prints the value of c which is 8

User Kyle Simek
by
4.3k points