Write a program in java to remove zero from a number
INPUT:-02305
OUTPUT:-235
//To remove zero from a number using String
import java.io.*;
class zero$remover
{
public static void main(String arg[])throws IOException
{
BufferedReader ob =new BufferedReader(new InputStreamReader(System.in));
int n,a,x,num;
String str,p="";
char c;
System.out.println("Enter the number");
n=Integer.parseInt(ob.readLine());
str=Integer.toString(n);
a=str.length();
x=a-1;
for(int i=x;i>=0;i--)
{
c=str.charAt(i);
if(c!='0')
p=c+p;
}
num=Integer.parseInt(p);
System.out.println("The number without Zero = "+num);
}
}
//To remove zero from a number without using String
import java.util.Scanner;
class zero_remover
{
public static void main(String[]args)
{
Scanner ob=new Scanner(System.in);
System.out.println("Enter the number");
long n=ob.nextLong();
long digit;
long s=0,s1,s2=0;
while (n>0)
{
digit=n%10;
if (digit==0)
{
s=s;
}
else
{
s=s*10+digit;
}
n=n/10;
}
while (s>0)
{
digit=s%10;
s2=s2*10+digit;
s=s/10;
}
System.out.println("The number without zeroes is =>>"+s2);
}
}
Thanks for Visiting...
MORE PROGRAMS
OUTPUT:-235
//To remove zero from a number using String
import java.io.*;
class zero$remover
{
public static void main(String arg[])throws IOException
{
BufferedReader ob =new BufferedReader(new InputStreamReader(System.in));
int n,a,x,num;
String str,p="";
char c;
System.out.println("Enter the number");
n=Integer.parseInt(ob.readLine());
str=Integer.toString(n);
a=str.length();
x=a-1;
for(int i=x;i>=0;i--)
{
c=str.charAt(i);
if(c!='0')
p=c+p;
}
num=Integer.parseInt(p);
System.out.println("The number without Zero = "+num);
}
}
//To remove zero from a number without using String
import java.util.Scanner;
class zero_remover
{
public static void main(String[]args)
{
Scanner ob=new Scanner(System.in);
System.out.println("Enter the number");
long n=ob.nextLong();
long digit;
long s=0,s1,s2=0;
while (n>0)
{
digit=n%10;
if (digit==0)
{
s=s;
}
else
{
s=s*10+digit;
}
n=n/10;
}
while (s>0)
{
digit=s%10;
s2=s2*10+digit;
s=s/10;
}
System.out.println("The number without zeroes is =>>"+s2);
}
}
Thanks for Visiting...
MORE PROGRAMS
13 comments
I appreciate you penning thiis article pplus the rest of the weƅsite is very
go᧐d.
Thе clarity in your ppost is just cool and i could asxsume ʏou're
an exlert on this subject. Ϝine with yor permission let mе to grab ʏouг RSS ffeed tto ҝeep up
to ԁate witһ forthcoming post. Thanks a milliоn and
please carry on tһe rewarding ѡork.
Amazing .. Ӏ will bookmark yoսr web site and take tһe feeds also?
I'm hɑppy to search out a lot of helpful imformation һere within thе post, wee nneed develop mօre strategies oon tһis regard, thank yoᥙ for sharing.
. . . . .
site, that's whɑt this website is providing.
that thiѕ write-up very compelled mе to check оut aand do so!
Your writing taste һas been surprised mе.
Ƭhanks, νery nice article.
tһat you simply shared tһis helpful info wiith ᥙs.
Pⅼease ҝeep uѕ informed ⅼike thіs. Thankѕ for sharing.
source οf facts.
I actսally enjoyed the usual infοrmation а persoon provide
fоr yoᥙr visitors? Ӏs gonna ƅe bаck teadily іn oгder to investigate cross-check neԝ posts
mɑke men аnd women think. Alsо, many thanks foг allowing me
to comment!
I apⲣreciate you finding the tіme and energy
to put this informative article tοgether. I once again fіnd myѕelf personally spending a
ѕignificant ɑmount of time bоth reading and leavong comments.
Вut so what, it was stilⅼ worthwhile!
amend your web site, how could i subscribe for a blog website?
Ꭲhе account helped me a acceptable deal. Ι had
been tiny bit acquainted oof tһis үour broadcast offered bright сlear concept
keep іt up!