6.Define a method to generate fibanacii series.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace fibanacii
{
class Program
{
public static void Fib(int n)
{
int i, c,a=0,b=1;
for (i = 0; i <= (n - 3); i++)
{
c = a + b;
a = b;
b = c;
Console.WriteLine(+c);
}
}
static void Main(string[] args)
{
int n,a = 0, b = 1;
Console.WriteLine("Enter fibonacci series of nth term : ");
n = int.Parse(Console.ReadLine());
Console.WriteLine("a={0},b={1}", a, b);
Fib(n);
}
}
};
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace fibanacii
{
class Program
{
public static void Fib(int n)
{
int i, c,a=0,b=1;
for (i = 0; i <= (n - 3); i++)
{
c = a + b;
a = b;
b = c;
Console.WriteLine(+c);
}
}
static void Main(string[] args)
{
int n,a = 0, b = 1;
Console.WriteLine("Enter fibonacci series of nth term : ");
n = int.Parse(Console.ReadLine());
Console.WriteLine("a={0},b={1}", a, b);
Fib(n);
}
}
};
No comments:
Post a Comment