Computer Science, asked by nishutiwari620, 2 months ago

Write the output for the following code of statements:
a.
a=100
b=20
S=0
while a>=b:
if a%5==0:
S+=a
a-=1
print(s)​

Answers

Answered by krsndp
11

Answer:

lets understand how to execute the code first

100 >= 20

if 100%5==0 (modular takes remainder as answer.so 0 will be true for it and loop will run)

s= s+a i.e. s= 0+ 100 ( so now value of s is 100)

a= a-1 i.e. a= 100 - 1 =99 ( value of a is now 99)

Value of S will be printed i.e 100

Control will move to first statemnt again

Now a =99

b=20

s=100

while 99>= 20

if 99%5==0 ( Condition here will be false as 4 will be the remainder. and 4==0 is false )

so

Value of S =100 is output

now

Similar questions