please help:'(
don't spam
Attachments:
Answers
Answered by
5
The equivalent while loop for this loop is as follows:
int p=0,I=1;
while(I<=5)
{
System.out.println(i+" ");
p=p+1;
i++;
}
System.out.println(p);
_____
Things to remember while converting from for loop to while loop.
- In for loop assignment, condition and the updation of loop variable are written together but not done in while loop
- In while loop if you need to assign the value of loop variable outside the loop then you have to give condition
- Then comes the statement... finally you update the loop value with +1 (i++ as given in the current snippet)
- Then close the loop
____
Learn more about While loop:-
- While loop is also known as entry controlled loop. As it first checks the condition then executes
- Once the condition is false, loop terminates
anindyaadhikari13:
Perfect.
Answered by
5
Explanation:
I hope it may help to you sis
Attachments:
Similar questions