C# Program to Check Whether the Entered Number is an Armstrong Number or Not

C# program to check whether the entered number is an armstrong number or not in C#.

using System;
using
System.Collections.Generic;
using
System.Text;

using System.Linq; 

namespace Armstrong
{

class
programme
{
    static void Main(string[] args)
    {
        int num,r,save,newnumber=0,count =0;
        console.writeline("enter the number");
        num = console.readline( );
        save= num;
        while(num !0)
        {
          r=num %10;
          newnum = newnum +pow(r,count);
          num = num/10;
       }
       if(newnum ==save)
       {

         console.writeline("number is armstrong number");
       }

       else

      {

         console.writeline("number is not armstrong number");

         console.readline();

      }

    }

}
Ebook Download
View all
Learn
View all