Computer Science, asked by guptameenalko0522, 4 months ago

Rewrite the following code using while loop
for(int i=1;i<=10;i++)
{ System.out.println(i);
S=S+t:
)
for loan​

Answers

Answered by anindyaadhikari13
4

Question:-

➡ Rewrite the following code using while loop

Solution:-

Given code,

for(int i=1;i<=10;i++)

{

System.out.println(i);

s=s+t;

}

Using while loop, we can write in this way,

int i=1;

while (i++<=10)

{

System.out.println(i);

s=s+t;

}

Answered by Oreki
2

Rewritten using While loop:

int i = 0;

while (i <= 10) {

   System.out.println(i);

   S= S + t;

   i++;

}

Similar questions