Computer Science, asked by tanmayimaddali, 11 months ago

WAP to accept the number and print the number after removing all zeroes from it using while loop​

Answers

Answered by duttadeeptangsh
1

Answer:

I am writing the while part only.

System.out.println ("Enter any no.");

int n=sc.nextInt();

int i=n,r,s=0;

while(i>0)

{

r=i%10;

if(r!=0)

s=s*10+r;

i=i/10;

}

System.out.println ("Original No.: "+n+"\nNo. after removing zero(s): "+s);

sc is the Scanner variable

sc is the Scanner variable To import Scanner class write the below statement before writing the class and class name

import java.util.Scanner;

Hope it helps.

Similar questions