Q:

Write a C# program to create a function to swap the values of two integer numbers

0

Write a C# program to create a function to swap the values of two integer numbers

All Answers

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

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
 
class functionexcercise
{
    public static int Fibonaccisequence(int number)
    {
        int num1 = 0;
        int num2 = 1;
 
        for (int i = 0; i < number; i++)
        {
            int temp = num1;
            num1 = num2;
            num2 = temp + num2;
        }
        return num1;
    }
    public static void Main()
    {
        Console.Write("Enter a number : ");
        int num = Convert.ToInt32(Console.ReadLine());
 
        Console.WriteLine("The Fibonacci series of " + num + " numbers is :");
        for (int i = 0; i < num; i++)
        {
            Console.Write(Fibonaccisequence(i) + "  ");
        }
        Console.ReadLine();
    }
}

Result:

Enter a number : 10

The Fibonacci series of 10 numbers is :0  1  1  2  3  5  8  13  21  34 

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

total answers (1)

Write a C# program to create a function to display... >>
<< Write a C# program to create a function to check w...