forked from seeditsolution/cprogram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNeon
28 lines (28 loc) · 697 Bytes
/
Neon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#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;
//Ask to enter the number
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;
}