Computer Science, asked by Anonymous, 5 days ago

Rewrite the following programs: 1) Using for loop:
int n,r;
Scanner in = new Scanner(System.in); System.out.println("Enter a number"); n = in.nextInt();
while(n!=0)
{
r=n%10;
n=n/10;
System.out.println(r); }

Answers

Answered by poonamanil84
1

Explanation:

import java.util.*;

class Number

{

public static void main(String args[])

{

int n,r;

Scanner in = new Scanner(System.in);

System.out.println("Enter a number");

n=in.nextInt();

while (n != 0) {

r=n%10;

n=n/10;

System.out.println(r);

}

}

}

please mark me brainliest

Answered by AthharvaPatil21
1

Answer:

import java.util.*;

class test3

{

public static void main()

{

int n=0,r=0;

Scanner in=new Scanner(System.in);

System.out.println("Enter a number:");

n=in.nextInt();

for(;n!=0;n/=10)

{

r=n%10;

System.out.println(r);

}

   }

}

Explanation:

Take Care bro

Similar questions