Thursday, 16 October 2014

Program to print Fibonacci Numbers below 100 in c#


using System;
class myclass
{
    static void Main()
    {
        int fn = 0;
        int sn = 1;
        int tn = 1;

        Console.WriteLine(fn);
        Console.WriteLine(sn);
        while (true)
        {

            tn = fn + sn;
            if (tn >= 100)
            {
                break;
            }
            Console.WriteLine(tn);
            fn = sn;
            sn = tn;

        }
        Console.Read();

    }
}


No comments:

Post a Comment