0

the question is:

Wrtie a program to modify the elements of an array such that the elements that are multiples of 10 swap with the values present in the very next position.

I wrote the following code:

```
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
void main()
{
clrscr();
int a[20];
int n,q=0;
cout<<"How many Numbers would you like to Enter?";
cin>>n;
for (int i=0;i<n;i++)
{
cout<<"Enter Value for Number "<<(i+1)<<": ";
cin>>a[i];
}
for (int j=0;j<n;j++)
{if (a[j]%10==0)
{a[j]=q;
a[j]=a[j+1];
a[j+1]=q;
i++;
}
}
for (int k=0;k<n;k++)
{cout<<a[k]<<endl;}
getch();
}
```

so if i give the input as:

How many Numbers would you like to Enter? 5

Enter Value for Number 1: 12

Enter Value for Number 2: 10

Enter Value for Number 3: 14

Enter Value for Number 4: 16

Enter Value for Number 5: 18

the output should be

12

14

10

16

18

but instead the output is:

12

14

16

18

3838

Pls tell what i should change in the program so as to get the correct output.