Write a program in c# (c sharp) to find out the Armstrong Numbers between series of 100 -500 numbers.
using System;
namespace ArmStorngNumber
{
class Program
{
static void Main(string[] args)
{
int num, sum, d, i, j;
Console.WriteLine("Armstrong Numbers between 100 to 500:");
for (i = 100; i <= 500; i++)
{
j = 1;
sum = 0;
num = i;
while (j <= 3)
{
d = num % 10;
sum = sum + (d * d * d);
num = num / 10;
j++;
}
if (sum == i)
{
Console.WriteLine(i);
}
}
Console.ReadKey();
}
}
}
If anyone have any doubt about the program , please comment and you can also mail me on "ibsarmschauhan13@gmail.com"
Thank you so much :)
No comments:
Post a Comment