open a console application project in c# language in your editor and just paste the following code in your class's brackets -
static void Main(string[] args)
{
int previous = -1; int next = 1;
int position;
Console.WriteLine("Enter the position");
position = int.Parse(Console.ReadLine());
for (int i = 0; i < position; i++)
{
int sum = next + previous; previous = next;
next = sum;
Console.WriteLine(next);
}
Console.ReadLine();
}
static void Main(string[] args)
{
int previous = -1; int next = 1;
int position;
Console.WriteLine("Enter the position");
position = int.Parse(Console.ReadLine());
for (int i = 0; i < position; i++)
{
int sum = next + previous; previous = next;
next = sum;
Console.WriteLine(next);
}
Console.ReadLine();
}
Output is -

wrong, position 9 is 34. you are not showing position 9, position 8 = 21.
ReplyDeleteshut-up man,,, do it your-self, dis program is fine...
Deletegood
ReplyDelete