Sunday, 1 September 2013

swapping of two values by call by value.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace callByValue
{
    class Program
    {
       public static void swap(int a, int b)
       {
           a = a + b;
           b = a - b;
           a = a - b;

           Console.WriteLine("after swapping value of a {0} and b {1}",a,b);
       }


       static void Main(string[] args)
       {
           int c=10, d=20;
           Console.WriteLine("before swapping  value of a {0} and b is{1}",c,d);
           
              swap(c,d);


             
           
       }
    }
}

No comments:

Post a Comment