You're online now.

Hurray! you are online now.

Neon Number c programming language

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;
    }

Algorithm to check neon number

  1. TAKE input(n)
  2. SET sq = n * n
  3. SET sum = 0
  4. REPEATE step 5, step 6, step 7 while sq > 0
  5. SET int digit = sq % 10
  6. sum = sum + digit
  7. sq = sq / 10
  8. CHECK (n == sum) then PRINT “Given number is neon number” otherwise go to step 9.
  9. PRINT “Given number is not neon number”
  10. EXIT
🖤 0
Buy me coffee ☕

Comments

Oops!

No comments here...