using System;
public class Program
{
public static void Main()
{
int i=0, num;
Console.WriteLine('Enter any number to check for Armstrong');
num=int.Parse(Console.ReadLine());
int count=num;
int number=num;
int res=0;
while(count!=0)
{
count=count/10;
i++;
}
//Console.WriteLine(i);
while(number!=0)
{
int mul=1;
int rem;
rem=number%10;
int cnt=i;
while(i!=0)
{
mul=mul*rem;
i--;
}
res=res+mul;
i=cnt;
number=number/10;
mul=1;
}
if(res==num)
{
Console.WriteLine(num+' is an Armstromg Number');
}else
{
Console.WriteLine(num+' is not an Armstrong number');
}
}
}
Output:
Enter any number to check for Armstrong
340
340 is not an Armstrong number
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
C# program to check any number is Armstrong or not.
Program:
Output: