WAP In java with the help of scanner class to accept a number and display the new number after removing all the zeroes.
Answers
Answered by
1
import java.util.*;
class Removing_Zero
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int n,r,x,s=0,rev=0,p;
System.out.println("Enter the no ");
n=sc.nextInt();
while(n>0)
{
r=n%10;
if(r==0)
{
x=r;
}
else
{
p=r;
rev=rev*10+p;
}
n=n/10;
}
while(rev>0)
{
r=rev%10;
s=s*10+r;
rev=rev/10;
}
System.out.println("Removing Zero: "+s);
}
}
class Removing_Zero
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int n,r,x,s=0,rev=0,p;
System.out.println("Enter the no ");
n=sc.nextInt();
while(n>0)
{
r=n%10;
if(r==0)
{
x=r;
}
else
{
p=r;
rev=rev*10+p;
}
n=n/10;
}
while(rev>0)
{
r=rev%10;
s=s*10+r;
rev=rev/10;
}
System.out.println("Removing Zero: "+s);
}
}
Similar questions