Advertisements
Advertisements
प्रश्न
State the type of loop in the given program segment
for (int i = 5; i l = 0; i =2)
System.out.println(i);
पर्याय
finite
null
infinite
fixed
MCQ
Advertisements
उत्तर
finite
Explanation:
This loop will execute as follows:
- Starts at
i = 5 -
Decrements
iby 2 each time (i -= 2) -
Runs while
i >= 0 - Values printed: 5, 3, 1
shaalaa.com
Entry Controlled Loop
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
APPEARS IN
संबंधित प्रश्न
Which of the following are entry-controlled loops?
- for
- while
- do..while
- switch
To execute a loop 10 times, which of the following is correct?
How many times will the following loop execute? Write the output of the code:
int x=10;
while(true) {
System.out.println(x++*2);
if(x%3==0)
break;
}