Hi,
Output=
***
***
***
***
Explanation:
The code starts with intial value of i=10;
In the next line, we have one ‘while’ loop.
Iteration 1-
It evaluates the condition if i>=3. The condition is true. So the control goes inside the while loop. Now ‘i=i-1’ decrements the value of i by 1. So now i=9. Now if i%2==1 is true as 9%2==1 is true so the loop continues in the loop. In the next step, print ‘***’. In the next step value of i is again decremented to 1 so new value of i=8. In the next line condition 8==4 is false so the loop starts over again.
Console status-
***
Iteration 2-
It evaluates the condition if i>=3. As 8>=3, the condition is true. So the control goes inside the while loop. Now ‘i=i-1’ decrements the value of i by 1. So now i=7. Now if i%2==1 is true as 7%2==1 is true so the loop continues in the loop. In the next step, print ‘***’. In the next step value of i is again decremented to 1 so new value of i=6. In the next line condition 6==4 is false so the loop starts over again.
Console status-
***
***
Iteration 3-
It evaluates the condition if i>=3. As 6>=3, the condition is true. So the control goes inside the while loop. Now ‘i=i-1’ decrements the value of i by 1. So now i=5. Now if i%2==1 is true as 5%2==1 is true so the loop continues in the loop. In the next step, print ‘***’. In the next step value of i is again decremented to 1 so new value of i=4. In the next line condition 4==4 is true so the control comes out of the loop
Console status-
***
***
***
Iteration 4-
It evaluates the condition if i>=3. As 4>=3, the condition is true. So the control goes inside the while loop. Now ‘i=i-1’ decrements the value of i by 1. So now i=3. Now if i%2==1 is true as 3%2==1 is true so the loop continues in the loop. In the next step, print ‘***’. In the next step value of i is again decremented to 1 so new value of i=2. In the next line condition 2==4 is false so the control comes out of the loop
Console status-
***
***
***
***
“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”
What Students Are Saying About Us
.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐"Honestly, I was afraid to send my paper to you, but splendidwritings.com proved they are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"
.......... Customer ID: 14***| Rating: ⭐⭐⭐⭐⭐
"The company has some nice prices and good content. I ordered a term paper here and got a very good one. I'll keep ordering from this website."