Computer Science, asked by kuanshul9715, 9 months ago

Write a program in qbasic to check whether a given number is a neon number or not

Answers

Answered by manfaridabad
3

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:

Answered by arpitdas796
0

Explanation:

HOPE IT WILL HELP ALL MY FRIENDS!!

Attachments:
Similar questions