0% found this document useful (0 votes)
37 views2 pages

ASSIGNMENT by Fasih Dawood Roll # 1612118: Code of Swapping

This document contains code for swapping the values of two integer variables, a and b, using XOR operations. It defines the variables a and b, initializes them to 12 and 4, prints their initial values, performs the XOR swaps to exchange the values, and then prints the swapped values of a and b. The code uses XOR (^) operations to swap the values of the two variables without needing a temporary variable to store one of the original values during the swap.

Uploaded by

Fasih Dawood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

ASSIGNMENT by Fasih Dawood Roll # 1612118: Code of Swapping

This document contains code for swapping the values of two integer variables, a and b, using XOR operations. It defines the variables a and b, initializes them to 12 and 4, prints their initial values, performs the XOR swaps to exchange the values, and then prints the swapped values of a and b. The code uses XOR (^) operations to swap the values of the two variables without needing a temporary variable to store one of the original values during the swap.

Uploaded by

Fasih Dawood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 2

ASSIGNMENT By Fasih Dawood

Roll # 1612118

CODE OF SWAPPING:
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ConsoleApplication3

class Program

static void Main(string[] args)

int a = 12, b = 4;

Console.WriteLine("\nValues Before Swap a= {0} ,b = {1} ", a,b );

a = a ^ b;

b = a ^ b;

a = a ^ b;

Console.WriteLine("\nValues After Swap a= {0} ,b = {1} ", a, b);

Console.ReadLine();

}
}

You might also like