Explain interconversion of loops with a example.
No googl'e use
Answers
Conversion from for loop to while loop are often asked so, I will convert a basic for loop to a while loop in Java.
To a while loop
So, first declaration of the iteration variable,
Then, the while loop,
Now the updation/incrementation,
conversion from for loop to while loop are often asked So, I will convert a basic for loop to a while loop in Java.
Example -
for (int i = 1 ; I < 20 ; i + = 2 ) {
int number = i* 2
system. out. print In (number) ;
}
To a while loop
So, first declaration of the iteration
variables,
int i = 1 ;
Then, the while loop,
while (i < 20) {
int number = i * 2
system. out. print In (number) ;
Now the updation/incremenation
i + = 2 ;
}
Explanation:
@Ask The MASTER