Q19. Write a code to print all distinct elements of a given integer array

Distinct Element :- Distinct elements are nothing but the unique (non-duplicate) elements present in the given array.

Algorithm Distinct Elements In An Array

//Algorithm To Print All Distinct Elements Of A Given Integer Array.
START
Step 1 -> Take array as input arr.
Step 2 -> calculate size of array
Step 3 -> for loop i to n:
for loop j to i:
if arr[i] == arr[j]:
break;
if i == j:
print arr[i]
STOP

Code for Distinct Elements In An Array

Output

5,4,2,8,7,6

Recommended Programs
Program to find factorial of a number
Program to count number of digits in a number