Sandeep Banerjee

Sandeep Banerjee

  • NA
  • 249
  • 264.9k

program to find armstrong number between 1 to 1000

Mar 14 2015 11:27 PM
sir, 
why this code is not work i is run only for 1
 
using System;
public class Arm2
{
public static void Main()
{
int reminder, i, num;
for(i=1; i<1000; i++)
{
int sum = 0;
num = i;
while(num>0)
{
reminder = num % 10;
sum = reminder*reminder*reminder;
num = num/10;
}
if(sum == i)
{
Console.WriteLine("{0} is armstrong number.", i);
}
}
Console.ReadLine();
}
}
 

Answers (2)