Armstrong Program in C#


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 Advertisements
Download Projects

Google Adsense Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 300X250 Contact on: hitesh.xc@gmail.com WhatsApp no. 8882538826

Yahoo Advertisements