Armstrong Number in C# with example

In this post, we will learn about Armstrong Number in C# with example.


In my previous posts I have explained various topics like Get site visitor count in
Convert generic list to datatable in Asp.Net C#.Net, Abstract Class in C# with Example,
Routing in Asp.Net MVC with Example
,Use of Global.asax in

Now in this post, I will explain how to check whether the number is Armstrong or not.

Armstrong number is a number which is equal to the sum of cubes of its own digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.

Now create Console Application in Visual Studio and write below lines of code in it.

using System;

namespace DotNetK
    class Program
        static void Main(string[] args)
            // C# program to check whether the number is Armstrong or not

            int _Number, r, sum = 0, temp;
            Console.Write("Enter the Number= ");
            _Number = int.Parse(Console.ReadLine());
            temp = _Number;

            while (_Number > 0)
                r = _Number % 10;
                sum = sum + (r * r * r);
                _Number = _Number / 10;
            if (temp == sum)
                Console.Write("It is Armstrong Number.");
                Console.Write("Not An Armstrong Number.");

            Console.ReadKey(); // To hold the console screen.

Read :


You can also read about ASP.NET, C#.Net, JQUERY, AJAX, JavaScript
I hope you get an idea about Armstrong Number in C# with example.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you liked this post, don’t forget to share this.

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *