What is the final values of the variable a band i in the end

What is the final values of the variable a, band i in the end of the following program? Program test dim a as byte dim b as byte dim i as byte main a = 0 b = 1 I = 0 while b 0 then for i = 0 to 5 b = b + 1 next I else do a = a + 2 loop until a > 5 end if wend end 8 LEDs were connected to the portC of a PIC microcontroller. Every 2 second half of them will turn next i on and others will turn off. It changes every 2 second. else After 10 second all LEDs will turn off and program will do stop. Write to necessary code.

Solution

Final value of a = 6, and b = 7, i=6.

while(b<7)

FIRST ITERATION::

then a is equal to 0. So pointer will move to else part i.e., a=a+2, and this loops untill a=6. hence final value of a = 6.

2nd ITERATION::

Now again pointer will come to while part i.e., (b<7) since b is still 0 here, so pointer will evaluate \' if \' part hence the value of b now becomes 7. The loop will iterate to i=0 to i=5 till i has value 6. When i gets the value 6 the program terminates.

 What is the final values of the variable a, band i in the end of the following program? Program test dim a as byte dim b as byte dim i as byte main a = 0 b = 1

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site