Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "iostream"
using std::cout;
int main()
{
const int sizeOfArray = 5;
int array1[sizeOfArray] ={1,1,2,2,3};
int array2[sizeOfArray];
int dup = 0;
int i, j;
for(i = 0; i < sizeOfArray; i++)
{
for(j = 0; j < dup; j++)
{
if(array1[i]==array2[j])
break;
}
if(j==dup)
{
array2[dup++] = array1[i];
}
}
cout << "Array after removing duplicate elements\n";
for(i = 0; i < dup; i++)
cout << array2[i] << " ";
return 0;
}

You might also like