Questions
Introduction To Object Oriented Programming (082025-CMM)
Single choice
Consider the following code : int i = 0; while (i < 5) { MessageBox.Show(i.ToString()); i++; } Which of the following is correct?
Options
A.a. The loop will only run once
B.b. The loop will run indefinitely
C.c. The loop will display numbers 1 to 5
D.d. The loop will display numbers 0 to 4

View Explanation
Verified Answer
Please login to view
Step-by-Step Analysis
To analyze what the loop does, I’ll step through how the code executes on each iteration.
First, the variable i is initialized to 0. The while condition checks i < 5 before each iteration, so the loop will run as long as i is less than 5. Inside the loop, the current value of i is shown via MessageBox.Show(i.ToSt......Login to view full explanationLog in for full answers
We've collected over 50,000 authentic exam questions and detailed explanations from around the globe. Log in now and get instant access to the answers!
Similar Questions
What is the output of the following code? int i = 2; int j = 4; while (i < j) { i++; j--; } MessageBox.Show(i.ToString());
What is the output of the code snippet given below? s = "abcde" i = 1 while i < 5 : if i > 1 : print(s[i])
How many times does the following code fragment display "Hi"? i = 10 while i >= 0 : print("Hi") i = i - 1
How many times will the following loop run? i = 0 while i < 10 : print(i) i = i + 1
More Practical Tools for Students Powered by AI Study Helper
Making Your Study Simpler
Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!