Computer Science, asked by ShivangiBhardwaj, 7 months ago

answer it properly please​

Attachments:

Answers

Answered by DrNykterstein
2

The loop would run only twice.

Here is why,

It is given the condition that when a is divided by 6 and leaves remainder 0. (That's what the modulas operator is doing here, It returns the remainder when two numbers are divided.)

Also, In the increment case, a is being increased by 4.

So, In the first cycle,

a would be 10 which is indeed not divisible by 6 hence the else statement would be executed.

In the second cycle,

a would be 14 which is also not divisible by 6. so the else statement is executed.

Now, In the third cycle,

a is 18 which is exactly divisible by 6, so the if statement is called and in that statement break keyword is used which breaks the loop, So, The loop would be stopped here.

Now, That the loop runs twice, Hence the value of a would be printed twice.

Output :

10

14

Some Information :-

☛ A loop is a block of statement that repeats itself for number of times as we want. It can also go on forever depends on what the condition is.

  • A loop is stopped when the given condition evaluates false.
  • A loop can be skipped and stopped by using the continue and break keywords respectively.

Similar questions