for (i = 0, j = mid; i < arr.Length - 1, j < arr.Length; i++,j++)
is it write ..? if wrong please help me ,
What I have tried:
Swapping of array elements program:
{10,20,30,40,50,60,70,80,90,100};
{60,70,80,90,100,10,20,30,40,50}
static void Main()
{
int i, j, temp,mid;
int[] arr = new int [10] {10,20,30,40,50,60,70,80,90,100};
Console.WriteLine("Array before swapping is : ");
foreach (int a in arr)
{
Console.WriteLine(a + "\t");
}
mid = (arr.Length)/2;
for (i = 0, j = mid; i < arr.Length - 1, j < arr.Length; i++,j++)
{
temp = arr[i];
arr[i] = arr[mid + 1];
arr[mid + 1] = temp;
}
Console.WriteLine("Array before swapping is : ");
foreach (int a in arr)
{
Console.WriteLine(a + "\t");
}
Console.ReadKey();
}