How to swap two numbers using function C#

1 Answer

0 votes
using System;

class Program
{
    static int swap(int a, int b) {
       return a;
    }

    static void Main()
    {
        int a = 4, b = 1;
        
        a = swap(b, b = a);

        Console.Write(a + " " + b); 
    }
}



/*
run:

1 4

*/

 



answered Apr 30, 2019 by avibootz

Related questions

1 answer 268 views
1 answer 683 views
1 answer 241 views
1 answer 276 views
5 answers 539 views
539 views asked Aug 22, 2022 by avibootz
1 answer 302 views
...