using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public class ARMSTRONGNUMBER
{
static void Main(string[] args)
{
int num, x, sum = 0;
Console.WriteLine("enter the Number");
num = int.Parse(Console.ReadLine());
for (int i = num; i > 0; i = i / 10)
{
x = i % 10;
sum = sum + x * x * x;
}
if (sum == num)
{
Console.WriteLine("The Number is Armstrong Number");
}
else
Console.WriteLine("The Number is not a Armstrong Number");
Console.ReadLine();
}
}
}
Explain : This program can be gives us to find out the given number is Armstrong or Not.
For example the given number is 153 =(1*1*1)+(5*5*5)+(3*3*3) then display the same number i.e is called the Armstrong number.Otherwise Non-Armstrong number.
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public class ARMSTRONGNUMBER
{
static void Main(string[] args)
{
int num, x, sum = 0;
Console.WriteLine("enter the Number");
num = int.Parse(Console.ReadLine());
for (int i = num; i > 0; i = i / 10)
{
x = i % 10;
sum = sum + x * x * x;
}
if (sum == num)
{
Console.WriteLine("The Number is Armstrong Number");
}
else
Console.WriteLine("The Number is not a Armstrong Number");
Console.ReadLine();
}
}
}
Explain : This program can be gives us to find out the given number is Armstrong or Not.
For example the given number is 153 =(1*1*1)+(5*5*5)+(3*3*3) then display the same number i.e is called the Armstrong number.Otherwise Non-Armstrong number.
Output's:
1. enter the Number : 153
The Number is Armstrong Number
2 .enter the Number : 123
The Number is not Armstrong Number
1. enter the Number : 153
The Number is Armstrong Number
2 .enter the Number : 123
The Number is not Armstrong Number
Nice program thank u for sharing
ReplyDelete