Narcissistic Number C Program

2 Ways To Check A Narcissistic Number in C Programming

Learn How To Find if a Number is a Narcissistic Number or not in C Programming Language. It is important that we should know How A For Loop Works before getting further with the C Program Code.


What is a Narcissistic Number?

If the Sum of Digits of a Number raised to the power of the number of digits is equal to the Number/Integer, then it is a Narcissistic Number. It is similar to an Armstrong Number.

Example:

Three Digit Narcissistic Integer:
153 = (1 * 1 * 1) + (5 * 5 * 5) + (3 * 3 * 3)

Four Digit Narcissistic Number:
8208 = (8 * 8 * 8 * 8) + (2 * 2 * 2 * 2) + (0 * 0 * 0 * 0) + (8 * 8 * 8 * 8)

This program takes every individual digit from the Integer and calculates the digit raised to the power of the number of digits in the Integer. Adding these powers of every digits and then comparing it with the Integer. If Sum is equal to the Integer, then it is a Narcissistic Number.

Method 1: Check Narcissistic Number with While Loop in C Program


Method 2: Check Narcissistic Number with For Loop in C Program

Output

C Program To Check Narcissistic Number

In case you get any compilation errors in this C Program To Find Narcissistic Numbers or you have any doubt about it, let us know about it in the comment section below.

Recommended Programs
C Program To Subtract Two Numbers using Pointers
C Program To Convert Binary To Decimal Integers
C Program To Display Current Date and Time
Check Validity of a Triangle in C Programming
Print Map of India in C Programming
100+ C Programs For Programming Interviews

Tushar Soni

I am Tushar Soni, Co - Founder of CodingAlpha. I am a computer science student from India and passionate about Web Development and Programming. Connect with me on Facebook | LinkedIn | Google Plus

13 thoughts on “Narcissistic Number C Program

  • November 29, 2015 at 5:13 pm
    Permalink

    Thanks for such a definitive guide!

    Reply
  • December 27, 2015 at 1:30 pm
    Permalink

    Excellent Explanation. Thanks.

    Reply
  • May 2, 2016 at 3:21 pm
    Permalink

    Hey instead of taking digits from user, use on counter and get digits… it will help to generate armstrong/narcissistic number… Cheers…

    Reply
    • May 26, 2016 at 12:15 pm
      Permalink

      Yes Ashish! We can use even that approach to get the digits! Thanks for Information anyway! 🙂

      Reply
  • August 29, 2016 at 2:37 pm
    Permalink

    How can we count the Number of Digits in the Input given by the User?

    Reply
  • September 8, 2016 at 11:53 pm
    Permalink

    So, this is basically like an Armstrong Number with more than 3 digits, right?

    Reply
  • September 13, 2016 at 10:12 pm
    Permalink

    This seems to be similar to Armstrong Number. What I could sense is that when an Armstrong Number with 4 digits or more needs to be calculated then it is called as Narcissiatic Number, right?

    Reply
  • October 22, 2016 at 11:38 am
    Permalink

    So, finally I have found the 4 digit armstrong number c program. Thanks to the creator of this code.

    Reply
  • November 2, 2016 at 11:51 pm
    Permalink

    This is so similar to Armstrong Number.

    Reply
  • November 16, 2016 at 1:19 am
    Permalink

    Very good explanation

    Reply

Join The Discussion