forked from MAYANK25402/Hactober-2023-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToFindNeonNumber.c
53 lines (41 loc) · 955 Bytes
/
ToFindNeonNumber.c
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// C program to demonstrate whether
// a number is Neon number or not
#include <stdio.h>
int Check_Neon_Number(int num) {
// Calculating the square of the number
int square = num * num;
// Copying the square in a variable
// to extract the digit
int n = square;
// Declaring a variable to store the digits
int digit;
// Initializing a variable to
// calculate the sum of digits
int sum = 0;
// To calculate the sum of digits
while (n != 0) {
// Extracting the digit
digit = n % 10;
sum = sum + digit;
n = n / 10;
}
// Checking the condition of a Neon Number
if (sum == num)
return 1; // If condition is true.
else
return 0; // If condition is false.
}
// Driver Code
int main()
{
int num = 9;
// Calling the function
int ans = Check_Neon_Number(num);
if (ans == 1)
// The number is Neon
printf("true");
else
// The number is not Neon
printf("false");
return 0;
}