3: Convert the following for loop into while loop and write the output also
for (int m=3;m<40/m=m+10)
(System.out.println (m);)
Answers
Answer:
When the statements are repeated sequentially a number of times in a program, the construct is known as:
iteration ✓
sequence
selection
none
Question 2
Which of the following statement is exit controlled loop?
for
while
do-while ✓
if-else
Question 3
Which of the following loop does not execute even once if condition is false in the beginning?
do-while
while ✓
for ✓
nested loop
Question 4
To execute a loop 10 times, which of the following statement satisfies:
for(i=6;i<=26;i=i+2)
for(i=3;i<=30;i=i+3) ✓
for(i=0;i<10;i=i++)
all of the above
Question 5
Which of the following statement uses multiple branches?
loop
continue
switch ✓
break
Question 6
Which of the following loop checks the condition first and then execution begins?
do-while
do
while loop ✓
for ✓
Question 7
To find the sum of whole numbers upto 10, a loop runs:
once
ten times
eleven times ✓
any number of times
Question 8
How many times the loop, for (i=1; ;i++), will execute, if there is no statement to terminate the loop?
1
0
infinite ✓
none
Question 9
Which of the following statements uses a case called default?
do-while
while
switch ✓
all of the above
Question 10
A loop statement is given as:
for(i=10;i<10,i++)
{
Statement
}
For how many times will the given loop statement be executed:
never ✓
1 time
10 times
infinite
Answer the Following Questions
Question 1
What do you understand by iterative process? How can it be resolved by using loop?
Iterative process means repeating a set of actions a certain number of times to perform some task. Loops in programming languages like Java enable us to repeat a single statement or a set of statements as long as the desired condition remains true.
Question 2
Explain for loop with an example.
for loop is an entry-controlled loop. Below is an example of for loop: