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
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
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