-->

Data File Handling

Question
CBSEENCO12011720

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

Solution
#include <iostream.h>
#include <conio.h>
void SWAP2BEST(int ARR[], int Size); 
int main ()
{
//Here we are taking different values for more perfect result with more
//numbers of array elements. You can change the values and number of array
//elements as per your choice.
	int ListofNum[8] = {6, 28, 30, 17, 50, 45, 80, 82};
	clrscr();
	SWAP2BEST(ListofNum, 8 ) ; 
	return 0;
}
void SWAP2BEST(int ARR[], int Size)
{
	int i= 0; int temp=0;
#include <iostream.h> 
#include <conio.h>
	void SWAP2BEST(int ARR[], int Size); 
	int main ()
	{
//Here we are taking different values for more perfect result with more
//numbers of array elements. You can change the values and number of array
//elements as per your choice.
		int ListofNum[8] = {6, 28, 30, 17, 50, 45, 80, 82};
		clrscr(); SWAP2BEST(ListofNum, 8 ) ;
		return 0;
	}
	void SWAP2BEST(int ARR[], int Size)
	{
		int i= 0; int temp=0;
for (i = 0; i < Size; ++i)//loop for printing original array values
{
	cout<<ARR[i]<<;
}
cout<<endl;
for (i = 0; i < Size; ++i)
{
	if(ARR[i+1]=='\0')
	{
	}
	else
	{
		if(ARR[i+1]%10==0)
		{
			temp=ARR[i];
			ARR[i]=ARR[i+1];
			ARR[i+1]=temp;
		}
	}
}
for (i = 0; i < Size; ++i)	//loop for printing swapped array value
{
	cout<<ARR[i]<<;
}
}