A Number is a Neon Number if the sum of digits of square of the number is equal to the number itself.
Example:
Given Number=9
square of 9=9*9=81
sum of digits of square=8+1=9
Problem statement:- Program to check whether the number is Neon Number or Not.
Data requirement:-
Input Data:- num
Output Data:- String output
Additional Data:- num1, sum, rem, sqr
Program in C
Example:
Given Number=9
square of 9=9*9=81
sum of digits of square=8+1=9
Problem statement:- Program to check whether the number is Neon Number or Not.
Data requirement:-
Input Data:- num
Output Data:- String output
Additional Data:- num1, sum, rem, sqr
Program in C
Here is the source code of the C Program to check whether the number is Neon Number or Not.
Code:
//Neon Number Or Not
#include<stdio.h>
int main()
{
int num,i;
printf("Enter the number:");
scanf("%d",&num);
int sqr=num*num;
//Sum of digit
int sum=0,rem;
while(sqr!=0)
{
rem=sqr%10;
sum+=rem;
sqr/=10;
}
if(sum==num)
printf("It is a Neon Number.");
else
printf("It is not a Neon Number.");
}
Input/Output:#include<stdio.h>
int main()
{
int num,i;
printf("Enter the number:");
scanf("%d",&num);
int sqr=num*num;
//Sum of digit
int sum=0,rem;
while(sqr!=0)
{
rem=sqr%10;
sum+=rem;
sqr/=10;
}
if(sum==num)
printf("It is a Neon Number.");
else
printf("It is not a Neon Number.");
}
Enter the number:9
It is a Neon Number.
Program in C++
Here is the source code of the C++ Program to check whether the number is Neon Number or Not.
It is a Neon Number.
Program in C++
Here is the source code of the C++ Program to check whether the number is Neon Number or Not.
Code:
#include <iostream>
using namespace std;
int main()
{
int num,i;
cout<<"Enter the number:";
cin>>num;
int sqr=num*num;
//Sum of digit
int sum=0,rem;
while(sqr!=0)
{
rem=sqr%10;
sum+=rem;
sqr/=10;
}
if(sum==num)
cout<<"It is a Neon Number.";
else
cout<<"It is not a Neon Number.";
}
Input/Output:using namespace std;
int main()
{
int num,i;
cout<<"Enter the number:";
cin>>num;
int sqr=num*num;
//Sum of digit
int sum=0,rem;
while(sqr!=0)
{
rem=sqr%10;
sum+=rem;
sqr/=10;
}
if(sum==num)
cout<<"It is a Neon Number.";
else
cout<<"It is not a Neon Number.";
}
Enter the number:1
It is a Neon Number.
Program in Java
It is a Neon Number.
Program in Java
Here is the source code of the Java Program to check whether the number is Neon Number or Not.
Code:
import java.util.Scanner;
public class NeonNumberOrNot {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
int num;
System.out.println("Enter a number:");
num=cs.nextInt();
int sqr=num*num;
//Sum of digit
int sum=0,rem;
while(sqr!=0)
{
rem=sqr%10;
sum+=rem;
sqr/=10;
}
if(sum==num)
System.out.println("It is a Neon Number.");
else
System.out.println("It is not a Neon Number.");
cs.close();
}
}
Input/Output:public class NeonNumberOrNot {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
int num;
System.out.println("Enter a number:");
num=cs.nextInt();
int sqr=num*num;
//Sum of digit
int sum=0,rem;
while(sqr!=0)
{
rem=sqr%10;
sum+=rem;
sqr/=10;
}
if(sum==num)
System.out.println("It is a Neon Number.");
else
System.out.println("It is not a Neon Number.");
cs.close();
}
}
Enter a number:
10
It is not a Neon Number.
10
It is not a Neon Number.
Program in Python
Here is the source code of the Python Program to check whether the number is Neon Number or Not.
Code:
num=int(input("Enter a number:"))
sqr=num*num
#Sum of digit
sum=0
while sqr!=0:
rem = sqr % 10
sum += rem
sqr //= 10
if sum==num:
print("It is a Neon Number.")
else:
print("It is not a Neon Number.")
sqr=num*num
#Sum of digit
sum=0
while sqr!=0:
rem = sqr % 10
sum += rem
sqr //= 10
if sum==num:
print("It is a Neon Number.")
else:
print("It is not a Neon Number.")
Input/Output:
0 Comments
Please do not Enter any spam link in the comment box