Q:

Method : call by value using C# Language

0

This Program is swap the number using method call by value concept

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 swap(int a,int b)

     {

         int t;

         t = a;

         a = b;

         b = t;

         Console.WriteLine("\nA value is : {0}",a);

         Console.WriteLine("\nB value is : {0}",b);

      }



     public static void Main()

       {

          int x,y;

   

           Console.Write("\nEnter the A value : ");

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



           Console.Write("\nEnter the B value : ");

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

           Console.WriteLine("\n"); 



           Console.WriteLine("The Given values are...");

           Console.WriteLine("\nA value is : {0}",x);

           Console.WriteLine("\nB value is : {0}",y);

           Console.WriteLine("\n"); 



           Console.WriteLine("After the Swap, the values are...");

           swap(x,y);

       }

    }

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