---
title: "Write a C# program to check given number is Armstrong or not?"  
description: "Write a C# program to check given number is Armstrong or not?"  
author: "Steilla Mitchel"  
published: 2021-11-18  
updated: 2021-11-18  
canonical: https://www.mindstick.com/forum/156853/write-a-c-sharp-program-to-check-given-number-is-armstrong-or-not  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Write a C# program to check given number is Armstrong or not?

Write a C# [program to check](https://www.mindstick.com/forum/157542/write-a-java-program-to-check-if-a-list-of-integers-contains-only-odd-numbers) given number is Armstrong or not?

## Replies

### Reply by Ashutosh Kumar Verma

[C# program](https://www.mindstick.com/forum/156830/how-do-i-make-a-c-sharp-program-that-checks-for-given-array-by-user-which-elements-are-perfect-numbers) to [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) any number is Armstrong or not.

## Program:

```
using System;
public class Program
{
 public static void Main()
 {
  int i=0, num;
  Console.WriteLine('Enter any number to check for Armstrong');
  num=int.Parse(Console.ReadLine());
  int count=num;
  int number=num;
  int res=0;
  while(count!=0)
  {
    count=count/10;
   i++;
  }
  //Console.WriteLine(i);
  while(number!=0)
  {
  int mul=1;
   int rem;
    rem=number%10;
   int cnt=i;
   while(i!=0)
   {
    mul=mul*rem;
    i--;
   }
   res=res+mul;
   i=cnt;
   number=number/10;
   mul=1;
  }
  if(res==num)
  {
  Console.WriteLine(num+' is an Armstromg Number');
  }else
  {
  Console.WriteLine(num+' is not an Armstrong number');
  }
 }
}
```

## Output:

```
Enter any number to check for Armstrong
340
340 is not an Armstrong number
```

## \


---

Original Source: https://www.mindstick.com/forum/156853/write-a-c-sharp-program-to-check-given-number-is-armstrong-or-not

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
