OverView:
In this article i would like to publish a Program to print Armstrong number between 1 to n using C#.Net.
Description:
A Number is said to be armstrong if it satisfies sum of cubes of an individual digits of a number is equal to that Number is called as a armstrong
153=13+53+33
Program:
In this article i would like to publish a Program to print Armstrong number between 1 to n using C#.Net.
Description:
A Number is said to be armstrong if it satisfies sum of cubes of an individual digits of a number is equal to that Number is called as a armstrong
153=13+53+33
Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace pr
{
class Class1
{
static void
Main(string[] args)
{
int no, temp, rem, sum, limit;
Console.WriteLine("Enter your Limit");
limit = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Armstrong Numbers between 1 to Limit");
for
(no = 1; no <= limit; no++)
{
temp = no;
sum = 0;
while
(temp > 0)
{
rem = temp % 10;
sum = sum + (rem * rem *
rem);
temp = temp / 10;
}
if
(no == sum)
{
Console.WriteLine(no);
}
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment