Rewrite the following loop using for loop:
int i=0;
while(i<=20)
{ System.out.print( i+” ”);
i++;
}
Answers
Answered by
0
Answer
assuming that it is from python 3 or above
Explanation:
i = 0
for i <= 20:
print(i)
i = i + 1
Answered by
0
Question:
Convert the following segment into equivalent for loop:
int i = 0;
while(i <= 20) {
System.out.print (i + " ");
i++;
}
Solution:
int i;
for(i=0;i<=20;i++)
{
System.out.print(i+" ");
}
Similar questions