# C-Programe to find neon number

A neon number is a number where the sum of digits of square of the number is equal to the number. For example, if the input number is 9, its square is 9*9 = 81 and the sum of the digits is 9. i.e. 9 is a neon.

In this program, you are going to learn that how to check a given number is neon or not.

#### Steps to check a given number is neon or not

1. Calculate the square of the given number.

2. Add each digit of the calculated square number.

3. compare the sum of digits of square of the number and number.

4. If the sum of digits equal to the number, then it is a neon otherwise it is not neon.

#include <stdio.h>
int isNeon(int num)
{
//storing the square of x
int square = 0;
//Store sum of digits (square number)
int sum_digits = 0;
//Calculate square of given number
square = (num * num);
while (square != 0)
{
sum_digits = (sum_digits + (square % 10));
square = (square / 10);
}
return (sum_digits == num);
}
int main()
{
int data = 0;
int isNeonNumber = 0;
printf(“Enter the number = “);
scanf(“%d”,&data);
// if is isNeonNumber is 1, then neon number
isNeonNumber = isNeon(data);
(isNeonNumber)? printf(“neon number\n\n”):printf(“Not a neon number\n\n”);
return 0;
}

Output:

Enter the number =9

neon number

You can also write a  program to check and print neon numbers in a given range.

#include <stdio.h>
int isNeon(int num)
{
//storing the square of x
int square = 0;
//Store sum of digits (square number)
int sum_digits = 0;
//Calculate square of given number
square = (num * num);
while (square != 0)
{
sum_digits = (sum_digits + (square % 10));
square = (square / 10);
}
return (sum_digits == num);
}
int main()
{
int data = 0;
int isNeonNumber = 0;
int loop = 0;
printf(“Enter the number upto you want check neon number = “);
scanf(“%d”,&data);
for (loop = 0; loop <= data; loop++)
{
// if is isNeonNumber is 1, then neon number
isNeonNumber = isNeon(loop);
if(isNeonNumber)
{
printf(” %d is neon number\n”,loop);
}
}
return 0;
}

Output:

0 is neone number

1 is neone number

9 is neone number