The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
Here your task to collect any number of elements in an array and you have to display an array with non duplicate elements.
Let us write our own c program to Remove Duplicate Elements From An Array
#include <stdio.h> int main() { int i, j, k, flag = 0, a[10], n; printf("Enter array size: "); scanf("%d",&n); for(i = 0;i < n;i++) scanf("%d ",&a[i]); printf("\n"); for(i = 0;i < n;i++) { for(j = i-1;j >= 0;j--) { if(a[i] == a[j]) { flag = 1; } } if(flag == 0) { printf("%d\t",a[i]); } flag = 0; } return 0; }
Enter array size : 6 1 1 2 3 4 5 1 2 3 4 5
The above program looks very simple, here goes the logic
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019