write a program to input a number and reverse it after removing all the zeros.using for loop in java
Answers
Answered by
0
I am going to write the main logic which u should use
int r, s= 0;
//input number as n
for(int i= n; i != 0; i=i/10) {
r = i%10;
if(r!=0)
s = s*10+r;
}
System.out.println(s);
int r, s= 0;
//input number as n
for(int i= n; i != 0; i=i/10) {
r = i%10;
if(r!=0)
s = s*10+r;
}
System.out.println(s);
Similar questions