Problem Statement: Write a C# program to generate a Fibonacci series of n terms. The program should display the first n numbers in the Fibonacci sequence.
Example:
Input: n = 10 Output: Fibonacci Series of 10 terms: 0 1 1 2 3 5 8 13 21 34
Steps to Print Fibonacci Series.
C# Sharp Code to Print Fibonacci Series.
// C-sharp code to print Fibonacci Series using System; namespace FibonacciSeries { class Program { static void Main(string[] args) { Console.Write("Enter the number of terms: "); int n = Convert.ToInt32(Console.ReadLine()); int firstTerm = 0, secondTerm = 1, nextTerm; Console.WriteLine($"Fibonacci Series of {n} terms:"); for (int i = 0; i < n; i++) { if (i <= 1) nextTerm = i; else { nextTerm = firstTerm + secondTerm; firstTerm = secondTerm; secondTerm = nextTerm; } Console.Write(nextTerm + " "); } } } }
Enter the number of terms: 8
Fibonacci Series of 8 terms:
0 1 1 2 3 5 8 13

Trends is an amazing magazine Blogger theme that is easy to customize and change to fit your needs.