Q:

Looping Statement : for Statement using C# Language

0

This Program is used to calculate the Fibonacci Series using for Statement

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;



public class exam

 {

    public static void Main()

    {

       int f,f1,f2,i,n;



       f1=-1;

       f2=1;

     

       Console.Write("Enter the Number : ");

       n = int.Parse(Console.ReadLine());



          for(i=0;i<n;i++)

            {

               f = f1+f2;

               Console.WriteLine("\n"+f);

               f1 = f2;

               f2 = f;

             }

       }

  }

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now