 # Armstrong Number in C#

Today in this article I will share you how to create Armstrong number in C#. This is the common question of any interviewer if you are fresher. So I explain in details what is Armstrong number.

What is Armstrong Number

An ARMSTRONG NUMBER is a number which is made up of N digits and which is equal to the sum of each digit raised to the Nth power.

Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.
Let's try to understand why 153 is an Armstrong number.
```153 = (1*1*1) + (5*5*5) + (3*3*3)
where:
(1*1*1)=1```
`(5*5*5)=125`
`(3*3*3)=27`
```So the Final Output is:
1+125+27=153```

Let's see the C# program to check Armstrong Number.
```using System;
public class ArmstrongExample
{
public static void Main(string[] args)
{
int  n,r,sum=0,temp;
Console.Write("Enter the Number= ");
temp=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(temp==sum)
Console.Write("Armstrong Number.");
else
Console.Write("Not Armstrong Number.");
}
}  ```
Output:
```Enter the Number= 153
Armstrong Number.
```
```Enter the Number= 342
Not Armstrong Number.```

Hope It will clear about the program Armstrong in C#. Still have any question regarding this, you can add the comments on below Disqus Forum.