write a c program to swap pair of elements in an array

Solutions on MaxInterview for write a c program to swap pair of elements in an array by the best coders in the world

showing results for - "write a c program to swap pair of elements in an array"
Ilana
07 Jan 2021
1/* C Program to Swap Two Arrays Without Using Temp Variable */
2#include<stdio.h>
3
4int main()
5{
6 int Size, i, a[10], b[10], Temp[10];
7  
8 printf("\nPlease Enter the Size of the Array\n");
9 scanf("%d", &Size);
10 
11 printf("\nPlease Enter the First Array Elements\n");
12 for(i = 0; i < Size; i++)
13  {
14      scanf("%d", &a[i]);
15  }
16   
17 printf("\nPlease Enter the Second Array Elements\n");
18 for(i = 0; i < Size; i ++)
19  {
20      scanf("%d", &b[i]);
21  }
22
23 //Swapping two Arrays 
24 for(i = 0; i < Size; i++)
25  {
26    a[i] = a[i] + b[i];
27    b[i] = a[i] - b[i]; 
28    a[i] = a[i] - b[i];
29  }
30
31 printf("\n a[%d] Array Elements After Swapping \n", Size); 
32 for(i = 0; i < Size; i ++)
33  {
34      printf(" %d \t ",a[i]);
35  }
36
37printf("\n\n b[%d] Array Elements After Swapping \n", Size); 
38 for(i = 0; i < Size; i ++)
39  {
40      printf(" %d \t ",b[i]);
41  }
42
43  return 0;
44} 
Hanna
01 Oct 2016
1write a c program to swap pair of elements 
queries leading to this page
swap function in c for arrayswap two values in array chow to swap two numbers in an array in cwrite a c program for swapping of two arraysswapping of array in cswap two array in c c program to swap two numbers explainedc swap two arraysswap every two integers in cfunction to swap array in cswap array in cswap in 2 array in cswap in int array in cswapping 2 arrays in for loops in cc program function to swap two elements in arrayc swap two parts of arrays cswap arrays cswap the numbers in array in chow to swap two numbers in array in cswap every two integers in array in cswapping two array elements in cswap elements of array in cswap function in c arrayswap two numbers in array in cswap function in c arraysswap arrays in cswap function for an array in cswapping of two numbers in an array in cswap two arraysswapping of two numbers in array in cc swap array elements within an arrayc swap two numers in arrayc swap two elements in arrayswap an array of arrays cc swap array elementsswapping two arrays in cc swap arrayswap array function in cswap 2 elements in array in cswap operation in c arraysc program to swap numbers between two arrayswapping of numbers using array in cswap array elements in carray swap using 2 variable in cc program to swap two arrayswrite a c program to swap pair of elements in an arrayc program to swap two numbers algorithmwrite a c program to swap elements of two variables and two arrays swap an array in carray swap chow to swap two places in ana array cwrite a c program for swapping of two arrays swap two elements in array cswap funcing an array in cswap two arrays in cswapping two elements in an array cswap 2 arrays in cwrite a c program to swap pair of elements in an array