input a number and display its even digits only in blue j
Answers
Answered by
2
Answer:
int n=Sc.nextInt();
while(n!=0)
{
d=n%10;
if (d%2==0)
System.out.println(d);
n/=10;
}
Answered by
4
Question:-
WAP to input a number and display it's even digit.
Program:-
import java.util.*;
class Number
{
public static void main(String s[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number: ");
int n=sc.nextInt();
System.out.print("Even digits are: ");
while(n!=0)
{
int d=n%10;
if(d%2==0)
System.out.print(d+" ");
n/=10;
}
}
}
Similar questions
Math,
2 months ago
Social Sciences,
2 months ago
Social Sciences,
2 months ago
History,
5 months ago
Math,
10 months ago
Physics,
10 months ago