C Program to Check Whether Given Number is Neon or Not on Command Line

You are going to learn the topic “C Program to Check Whether Given Number is Neon or Not on Command Line” using this tutorial. Shall I start the article to teach the prospects to you? Come on! Let’s go.

C Program to Check Whether Given Number is Neon or Not on Command Line

C Program to Check Whether Given Number is Neon or Not on Command Line

Program Code

#include <stdio.h>
 
int main()
{
    int num, digit, sum =0;
    
    //Input a number
    printf("Enter a number to check for neon number: n");
    scanf("%d",&num);
        
    //Calculate square of the input
    int square = num*num;
    
    //Sum the digits of the square
    while(square!=0){
        digit = square%10;
        sum += digit;
        square = square/10;
    }
    
    //Check if sum is equal to the input number
    if(sum == num)
        printf("Neon Number n");
    else
        printf("Not a Neon Number n");
 
    return 0;
}

Conclusion

I hope this article helps you to lean the topic “C Program to Check Whether Given Number is Neon or Not on Command Line” clearly. If you face any issues please let me know via the comment section. Share this article with other C/C++ developers via social networks. Thank You!

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment