Consider the following code
int amount =100;
while(amount>0)
{
System.out.println(amount);
amount=amount-1;
}
rewrite the above code using
i) do while loop
ii) for lloop
REPLY FAST
Answers
Answered by
1
Given code,
int amount=100;
while(amount>0)
{
System.out.println(amount);
amount=amount-1;
}
______________________
Q i) Convert into Do-while loop
int amount=100;
do
{
System.out.println(amount) ;
amount=amount-1;
}
while(amount>0) ;
_______________________
Q ii) Convert into For loop
for(amount=100; amount>0; amount--)
{
System.out.println(amount) ;
}
_______________________
#Solved_By_@Swetank232894
Similar questions