| 1. |
Write a program in qbasic to check whether a given number is a neon number or not |
|
Answer» Answer:his program checks if a number entered is a Neon Number or not, in JAVA. A number is said to be a Neon Number if the sum of digits of the square of the number is equal to the number itself. Example- 9 is a Neon Number. 9*9=81 and 8+1=9.Hence it is a Neon Number. Program - import java.util.*; public class NeonNumber { public static void MAIN(String ARGS[]) { Scanner ob=new Scanner(System.in); System.out.println("ENTER the number to be checked."); int num=ob.nextInt(); int square=num*num; int sum=0; while(square!=0)//LOOP to find the sum of digits. { int a=square%10; sum=sum+a; square=square/10; } if(sum==num) { System.out.println(num+" is a Neon Number."); } else { System.out.println(num+" is not a Neon Number."); } } Explanation: |
|