Computer Science, asked by arshpreets517, 9 months ago

f) Rewrite the following pattern by using do while.
Class Test
public static void main(string args[]
int x,c;
for (x=10,c=20;c>=10;c=c-2)
x++;
System.out.println(x);

Answers

Answered by Anonymous
6

public static void main(string args[]

int x,c;

do

{

x=10,c=20;

c=-2

}while(c>=10)

x++;

System.out.println(x)

Answered by AskewTronics
2

Repeated above Code in  java using DO while:

Explanation:

public class Test//take from the question.

{

public static void main(String args[])//taken from the question

{

       int x,c;//taken from the question

       x=10;//added the code.

       c=20;//added the code.

//below are the code which are added for the while loop.

       do

       {    

          x++;

          c=c-2;  

       }while(c>=10);

//The added code ends here.

       System.out.println(x);//taken from the question.

      }

}

Code Explanation:

  • The above code is written in the java language, in which the question holds the code using for loop.
  • But the above code is refreshed the question code using the do-while loop.
  • There is some syntax error in the question code which is fixed in the solution.

Learn More:

  • Java : https://brainly.in/question/13792074
Similar questions