Programming Examples

Java program to pass an integer as argument and check whether all digits in it are even digit or not


Write a program to pass an integer as argument and check whether all digits in it are even digit or not.

Solution

class AllEven
{
	public static void main(int a)
	{
		int i,d,f=0;
		for(i=a;i>0;i=i/10)
		{
			d=i%10;
			if(d%2!=0)
				f=1;
		}
		if(f==0)
			System.out.println("All are even digits");
		else
			System.out.println("All are not even digits");
	}
}
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 NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad