how to programming in c#.... Make your reasoning skills Powerful to boost your programming knowledge
C# Coding:
armstrong numbers are just like - 153 = 1*1*1 = 1 , 5*5*5 = 125, 3*3*3 = 27
1+125+27=153
You have to be skilly when writing a code:
just below is the Code...
int num, sum, y;
Console.WriteLine("Please write the number to know")
num=int.Parse(Console.ReadLine());
for(int i=num;i>0;i=i/10)
{
y=i%10;
sum=sum+y*y*y;
}
if(sum==num)
{
Console.WriteLine("Armstrong");
}
else
{
Console.WriteLine("Not Armstrong");
}
Console.ReadLine();
No comments:
Post a Comment