MENU
Question -

Write a function SWAP2BEST (int ARR[], int Size) in C+ + to modify the content of the array in such a way that the elements, which are multiples of 10 swap with the value present in the very next position in the array.
For example:
If the content of array ARR is
90,56,45,20,34,54
The content of array ARR should become
56,90,45,34,20,54



Answer -

 void SWAP2BEST (int ARR [] , int Size)
 {
 for (int n=0; n
 {
 if(ARR[n]%10 = =0)
 {
 int temp = 0;
 temp = ARR [n];
 ARR[n] = ARR[n+1];
 ARR [n+1] = temp;
 n++;
 }
 }
 }

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×