Dismiss Notice
You are browsing this site as a guest. It takes 2 minutes to CREATE AN ACCOUNT and less than 1 minute to LOGIN

How To Write a Code for Armstrong number or not using ASP.NET

Discussion in 'Tech, Gadgets & Science Forum' started by Boniface Evarist, Sep 4, 2012.

  1. Boniface Evarist

    Boniface Evarist JF-Expert Member

    #1
    Sep 4, 2012
    Joined: Nov 26, 2010
    Messages: 1,098
    Likes Received: 5
    Trophy Points: 135
    naomba msaada wa kuandika program ya asp.net to find out if the given number is Armstrong or not
     
  2. Kang

    Kang JF-Expert Member

    #2
    Sep 4, 2012
    Joined: Jun 24, 2008
    Messages: 4,698
    Likes Received: 203
    Trophy Points: 160
    Umefikia wapi?
     
  3. Boniface Evarist

    Boniface Evarist JF-Expert Member

    #3
    Sep 4, 2012
    Joined: Nov 26, 2010
    Messages: 1,098
    Likes Received: 5
    Trophy Points: 135

    class ArmStrongNumber
    {
    public static void Main()
    {
    Console.WriteLine("********** ArmStrong Number Check Example ********");
    Console.WriteLine("Enter Number to Want to check");
    int numberToCheck = int.Parse(Console.ReadLine());
    int lenthOfNumber = numberToCheck.ToString().Length;
    double reminder = 0;
    double sum = 0;
    int tempNo = numberToCheck;
    while (tempNo > 0)
    {
    reminder = tempNo % 10;
    sum = sum + Math.Pow(reminder, lenthOfNumber);
    tempNo = tempNo / 10;
    }
    if (sum == numberToCheck)
    {
    Console.WriteLine("The given Number {0} is a Armstrong Number", numberToCheck);
    }
    else
    {
    Console.WriteLine("The given Number {0} is NOT a Armstrong Number", numberToCheck);
    }
    Console.ReadLine();
    }


    }

    Je unaweza kunisaidia kuandika bila kutumia Console?
     
  4. Kang

    Kang JF-Expert Member

    #4
    Sep 5, 2012
    Joined: Jun 24, 2008
    Messages: 4,698
    Likes Received: 203
    Trophy Points: 160
    Bila console unataka kuzichukua wapi input na results kudisplay wapi?
     
Loading...