A neon number is a number if the sum of the square of that number is equal to the actual number, then it is a neon number. For Example : 9 is a neon number.
Let's check 9 is really neon or not. So the square of 9 is 81.
Now the sum of square each digits 8 + 1 = 9.
So, 9 is neon number.
// Check given number in neon
#include<stdio.h>
int main(){
int n;
printf("Enter the number : ");
scanf("%d", &n);
// sqaure the given number
int sq = n * n;
// declare a variable for storing the sum
int sum = 0;
while(sq>0){
int digit = sq % 10;
sum = sum + digit;
sq = sq / 10;
}
if(n == sum){
printf("%d is Neon Number", n);
}
else{
printf("%d is Not Neon Number", n);
}
return 0;
}
Comments
Oops!