How do you swap positions of elements in an array?
What is an array: Array is the collection of similar types of data items.
How do you swap positions of elements in an array
- arr[]={1,3,2,5,6,7,8,9};
- first of all, create a temp variable
- temp = arr[2];
- arr[2]= arr[5];
- arr[5] = temp;
- print arr[5];
Comments
Post a Comment