Check whether given number is neon number or not

Here given code implementation process.

``````//  C program
//  Check whether given number is neon number or not
#include <stdio.h>

// Check number is neon or not
void isNeon(int num)
{

// Calculate square of given number
int square =  num * num;

// Use to calculate digit sum element
int sum = 0;

// Execute loop until square of given number is not zero
while(square != 0)
{
sum    +=  square % 10;

// Remove last digit
square /= 10;
}

// Display given number
printf("\n Number : %d",num);

if(sum == num)
{
// When number is neon
printf("\n Yes ");
}
else
{
// When number is not neon
printf("\n No");
}

}
int main(int argc, char const *argv[])
{

// Test case
isNeon(1);
isNeon(5);
isNeon(9);

return 0;
}``````

Output

`````` Number : 1
Yes
Number : 5
No
Number : 9
Yes``````
``````/*
Java program
Compare two numbers without using comparison operator
*/
public class NeonNumber
{
// Check number is neon or not
public void isNeon(int num)
{
// Calculate square of given number
int square = num * num;
// Use to calculate digit sum element
int sum = 0;
// Execute loop until square of given number is not zero
while (square != 0)
{
sum += square % 10;
// Remove last digit
square /= 10;
}
// Display given number
System.out.print("\n Number : " + num);
if (sum == num)
{
// When number is neon
System.out.print("\n Yes ");
}
else
{
// When number is not neon
System.out.print("\n No");
}
}
public static void main(String[] args)
{
// Test case
}
}``````

Output

`````` Number : 1
Yes
Number : 5
No
Number : 9
Yes``````
``````// Include header file
#include <iostream>
using namespace std;
/*
C++ program
Compare two numbers without using comparison operator
*/
class NeonNumber
{
public:
// Check number is neon or not
void isNeon(int num)
{
// Calculate square of given number
int square = num *num;
// Use to calculate digit sum element
int sum = 0;
// Execute loop until square of given number is not zero
while (square != 0)
{
sum += square % 10;
// Remove last digit
square /= 10;
}
// Display given number
cout << "\n Number : " << num;
if (sum == num)
{
// When number is neon
cout << "\n Yes ";
}
else
{
// When number is not neon
cout << "\n No";
}
}
};
int main()
{
// Test case
return 0;
}``````

Output

`````` Number : 1
Yes
Number : 5
No
Number : 9
Yes``````
``````// Include namespace system
using System;
/*
C# program
Compare two numbers without using comparison operator
*/
public class NeonNumber
{
// Check number is neon or not
public void isNeon(int num)
{
// Calculate square of given number
int square = num * num;
// Use to calculate digit sum element
int sum = 0;
// Execute loop until square of given number is not zero
while (square != 0)
{
sum += square % 10;
// Remove last digit
square /= 10;
}
// Display given number
Console.Write("\n Number : " + num);
if (sum == num)
{
// When number is neon
Console.Write("\n Yes ");
}
else
{
// When number is not neon
Console.Write("\n No");
}
}
public static void Main(String[] args)
{
// Test case
}
}``````

Output

`````` Number : 1
Yes
Number : 5
No
Number : 9
Yes``````
``````<?php
/*
Php program
Compare two numbers without using comparison operator
*/
class NeonNumber
{
// Check number is neon or not
public	function isNeon(\$num)
{
// Calculate square of given number
\$square = \$num * \$num;
// Use to calculate digit sum element
\$sum = 0;
// Execute loop until square of given number is not zero
while (\$square != 0)
{
\$sum += \$square % 10;
// Remove last digit
\$square = intval(\$square / 10);
}
// Display given number
echo "\n Number : ". \$num;
if (\$sum == \$num)
{
// When number is neon
echo "\n Yes ";
}
else
{
// When number is not neon
echo "\n No";
}
}
}

function main()
{
// Test case
}
main();``````

Output

`````` Number : 1
Yes
Number : 5
No
Number : 9
Yes``````
``````/*
Node Js program
Compare two numbers without using comparison operator
*/
class NeonNumber
{
// Check number is neon or not
isNeon(num)
{
// Calculate square of given number
var square = num * num;
// Use to calculate digit sum element
var sum = 0;
// Execute loop until square of given number is not zero
while (square != 0)
{
sum += square % 10;
// Remove last digit
square = parseInt(square / 10);
}
// Display given number
process.stdout.write("\n Number : " + num);
if (sum == num)
{
// When number is neon
process.stdout.write("\n Yes ");
}
else
{
// When number is not neon
process.stdout.write("\n No");
}
}
}

function main()
{
// Test case
}
main();``````

Output

`````` Number : 1
Yes
Number : 5
No
Number : 9
Yes``````
``````#   Ruby program
#   Compare two numbers without using comparison operator

class NeonNumber
#  Check number is neon or not
def isNeon(num)
#  Calculate square of given number
square = num * num
#  Use to calculate digit sum element
sum = 0
#  Execute loop until square of given number is not zero
while (square != 0)
sum += square % 10
#  Remove last digit
square /= 10
end

#  Display given number
print("\n Number : ", num)
if (sum == num)
#  When number is neon
print("\n Yes ")
else
#  When number is not neon
print("\n No")
end

end

end

def main()
#  Test case
end

main()``````

Output

`````` Number : 1
Yes
Number : 5
No
Number : 9
Yes ``````
``````#   Python 3 program
#   Compare two numbers without using comparison operator

class NeonNumber :
#  Check number is neon or not
def isNeon(self, num) :
#  Calculate square of given number
square = num * num
#  Use to calculate digit sum element
sum = 0
#  Execute loop until square of given number is not zero
while (square != 0) :
sum += square % 10
square = int(square /
#  Remove last digit
10)

#  Display given number
print("\n Number : ", num, end = "")
if (sum == num) :
#  When number is neon
print("\n Yes ", end = "")
else :
#  When number is not neon
print("\n No", end = "")

def main() :
#  Test case

if __name__ == "__main__": main()``````

Output

`````` Number :  1
Yes
Number :  5
No
Number :  9
Yes``````
``````/*
Scala program
Compare two numbers without using comparison operator
*/
class NeonNumber
{
// Check number is neon or not
def isNeon(num: Int): Unit = {
// Calculate square of given number
var square: Int = num * num;
// Use to calculate digit sum element
var sum: Int = 0;
// Execute loop until square of given number is not zero
while (square != 0)
{
sum += square % 10;
// Remove last digit
square = (square / 10).toInt;
}
// Display given number
print("\n Number : " + num);
if (sum == num)
{
// When number is neon
print("\n Yes ");
}
else
{
// When number is not neon
print("\n No");
}
}
}
object Main
{
def main(args: Array[String]): Unit = {
var task: NeonNumber = new NeonNumber();
// Test case
}
}``````

Output

`````` Number : 1
Yes
Number : 5
No
Number : 9
Yes``````
``````/*
Swift 4 program
Compare two numbers without using comparison operator
*/
class NeonNumber
{
// Check number is neon or not
func isNeon(_ num: Int)
{
// Calculate square of given number
var square: Int = num * num;
// Use to calculate digit sum element
var sum: Int = 0;
// Execute loop until square of given number is not zero
while (square  != 0)
{
sum += square % 10;
// Remove last digit
square /= 10;
}
// Display given number
print("\n Number : ", num, terminator: "");
if (sum == num)
{
// When number is neon
print("\n Yes ", terminator: "");
}
else
{
// When number is not neon
print("\n No", terminator: "");
}
}
}
func main()
{
// Test case
}
main();``````

Output

`````` Number :  1
Yes
Number :  5
No
Number :  9
Yes``````
``````/*
Kotlin program
Compare two numbers without using comparison operator
*/
class NeonNumber
{
// Check number is neon or not
fun isNeon(num: Int): Unit
{
// Calculate square of given number
var square: Int = num * num;
// Use to calculate digit sum element
var sum: Int = 0;
// Execute loop until square of given number is not zero
while (square != 0)
{
sum += square % 10;
// Remove last digit
square /= 10;
}
// Display given number
print("\n Number : " + num);
if (sum == num)
{
// When number is neon
print("\n Yes ");
}
else
{
// When number is not neon
print("\n No");
}
}
}
fun main(args: Array < String > ): Unit
{
// Test case
}``````

Output

`````` Number : 1
Yes
Number : 5
No
Number : 9
Yes``````

Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.