Sunday, December 7, 2014

fibonacci series in asp.net, ArmStrong Number, PalindromeNumberOrNot





ArmStrong Number


namespace DotNetMirror
{
    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();
        }
    }
}
Fibonaci
using System;

namespace Fibonaccinumber
{
    class Program
    {
        static void Main(string[] args)
        {
           
            int a=0;     // assigning initaial value for first varible
            int b=1;     // assigning initaial value for second  varible
            int c=1;     // assigning initaial value for third varible

            Console.WriteLine(a);
            Console.WriteLine(b);
            while (true)
            {

                c = a + b; 
                if (c >= 200)
                {
                    break;
                }
                Console.WriteLine(c);
                a = b;
                b = c;

            }
            Console.Read();  // to keep windows screen after running

        }
    }
}

Palindrome
class PalindromeNumberOrNot
{
    public static void Main()
    {
        Console.WriteLine("********** Palindrome 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 * 10 + reminder;
            tempNo = tempNo / 10;

        }
        if (sum == numberToCheck)
        {
            Console.WriteLine("The given Number {0} is a Palindrome Number", numberToCheck);
        }
        else
        {
            Console.WriteLine("The given Number {0} is NOT a Palindrome Number", numberToCheck);
        }
    }
}