write a program to enter a number and check and print whether it is a tech number or not
Answers
Answered by
2
Answer: CODE :
import java.util.*;
class Tech_number
{
public static void main(String args[])
{
Scanner sc = new Scanner( System.in );
System.out.println("Enter the number");
int n=sc.nextInt();
int c=0;
while(n>0)
{
c++;
n=n/10;
}
if(c%2==0)
System.out.println("Tech number");
else
System.out.print("Not a tech number");
}
}
Explanation:
Take the input and count digits by using while loop .
Then check whether the number of digits is even or not .
Similar questions