Programming Examples

Java program to input an integer and remove all the even digits from it


Write a program to input an integer and remove all the even digits from it.

For Example,

INPUT: Enter an integer: 1234

OUPUT: 13

Solution

class RemoveEven
{
	public static void main(int a)
	{
		int i,d,s=0,c=0;
		for(i=a;i>0;i=i/10)
		{
		d=i%10;
		if(d%2!=0)
			s=s+d*(int)Math.pow(10,c++);
		}
		System.out.println("New number="+s);
	}
}
Output

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz