write a Java Program to check whether the entered number is Tech number or not
a tech number is a number which having even number of digits
Answers
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 .
Answer:import java.util.Scanner;
classTech
{
pulic static void main(String args[])
{
Scanner sc=new scanner (System.in);
int n,i,a,b,s,sq;
System.out.println("Enter a no.")
n=sc.nextInt();
for(i=1;i<=n;i++)
{
a=i\100;
b=i%100;
s=a+b;
sq=s*s;
if(sq==i)
Sopln(i+" ");
}}}
Explanation:Tech no is a four-digit even no. which when splitted into two equal halves, then the sum of square of these halves are equal to the no. itself. Eg- 3025= 30+25
=55
=(55)2 = 3025