I have an array elements like this:
int arr[] = {1,1,2,2,3,3,4,4};
I want to remove the duplicate elements from. Searched on the internet
int flag = 0, k = 0; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arrAns.length; j++) { if (arr[i] == arrAns[j]) { flag = 0; break; } flag=1; } if (flag == 1) { arrAns[k] = arr[i]; k++; } flag = 0; }