Armstrong Program in C#

Advertisements

Prev Tutorial Next Tutorial

Armstrong Number Program in C#

To find Armstrong number program we apply same concept like C and C++ programming. Some Armstrong numbers are 153 etc.

Check Given Number is Armstrong or not in C#

using System;
 
class Armstrong
{
public static void Main()
{
 int number, remainder, sum = 0;
 Console.Write("Enter any Number: ");
 number = int.Parse(Console.ReadLine());
 for (int i = number; i > 0; i = i / 10)
 {
  remainder = i % 10;
  sum = sum + remainder*remainder*remainder;
 }
  if (sum == number)
   {
    Console.Write("This is an Armstrong Number");
   }
 else
 {
 Console.Write("This is not an Armstrong Number");
 }
 Console.ReadLine();
 }
}

Output

Enter any Number: 153
This is an Armstrong Number

Output

Enter any Number: 133
This is not an Armstrong Number

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements