बिजनेस मार्केटिंग का लो कॉस्ट फंडा , अपने मोबाइल से ऑटो sms भेजकर मार्केटिंग करे विजिट करे http://autotextsms.com/ बिजनेस मार्केटिंग का लो कॉस्ट फंडा http://autotextsms.com/

Search This Blog

Translate

Showing posts with label Program to find the no of non repeated elements in an array. Show all posts
Showing posts with label Program to find the no of non repeated elements in an array. Show all posts

Program to find the no of non repeated elements in an array

Program to find the no of non repeated elements in an array 


#include <stdio.h>
 int main()
{ int array[50]; int *ptr; int i, j, k, size, n; printf("\n Enter size of the array: "); scanf("%d", &n); printf("\n Enter %d elements of an array: ", n); for (i = 0; i < n; i++) scanf("%d", &array[i]); size = n; ptr = array; for (i = 0; i < size; i++) { for (j = 0; j < size; j++) { if (i == j) { continue; } else if (*(ptr + i) == *(ptr + j)) { k = j; size--; while (k < size) { *(ptr + k) = *(ptr + k + 1); k++; } j = 0; } } } printf("\n The array after removing duplicates is: "); for (i = 0; i < size; i++) { printf(" %d", array[i]); } return 0; }

OUTPUT:- -----------------------------------
Enter size of the array: 7 Enter 7 elements of an array: 2 3 5 2 8 5 3 The array after removing duplicates is: 2 3 5 8
--------------------------------




C Program example List