Showing posts with label C# Program to find Armstrong number. Show all posts
Showing posts with label C# Program to find Armstrong number. Show all posts

Wednesday, November 14, 2018

C# Program to find Armstrong number

C# Program to find Armstrong Number

An Armstrong Number is an integer such that the sum of the cubes of its digits is equal to the number itself.

CODE:

1)Finding Armstrong number till 3 digits only


 using System;

namespace armstrongNumber
{
    class Program
    {
        static void Main(string[] args)
        {
            int no,r,sum=0,n=0;
            Console.WriteLine("Enter number\n");
            no = int.Parse(Console.ReadLine());
            n = no;
            while (n > 0)
            {
                r = n % 10;
                n = n / 10;
                sum += r*r*r;
            }

            if (sum == no)
            {
                Console.WriteLine(no+" is a Amstrong number" );
            }
            else
            {
                Console.WriteLine(no+" is not a Amstrong number");
            }
            Console.ReadLine();
        
        }
    }
}

IND vs AUS: Smith & Labuschagne Holds Fort As Fourth Test Ends Up In A Stalemate

  Beginning on 158 after Tea for the loss of two wickets for visiting Australian side with two stalwarts Steve Smith and   Marnus Labuschagn...