Answers

2015-09-25T08:18:10+05:30
#include<stdio.h>int main(){  int arr[50];  int *p;  int i,j,k,size,n;  printf("\nEnter size of the array: ");  scanf("%d",&n);  printf("\nEnter %d elements into the array: ",n);  for(i=0;i<n;i++)    scanf("%d",&arr[i]);  size=n;  p=arr;  for(i=0;i<size;i++){    for(j=0;j<size;j++){         if(i==j){             continue;         }         else if(*(p+i)==*(p+j)){             k=j;             size--;             while(k < size){                 *(p+k)=*(p+k+1);                 k++;              }              j=0;          }      }  }  printf("\nThe array after removing duplicates is: ");  for(i=0;i < size;i++){    printf(" %d",arr[i]);  }  return 0;}
1 4 1
some what inefficient program.. you do start comparing data from j = 0 onwards... you may do from j = i+1 onwards...
2015-09-29T21:11:31+05:30

This Is a Certified Answer

×
Certified answers contain reliable, trustworthy information vouched for by a hand-picked team of experts. Brainly has millions of high quality answers, all of them carefully moderated by our most trusted community members, but certified answers are the finest of the finest.
#include <stdio.h>

main()
{
  int A[100];  int i, j, n;
     printf"size: ");
     scanf("%d", &n);
     printf("values :  ");
      for (i=0; i<n;i++) scanf("%d", &A[i] );
    
     for (i = 0; i < n ; i++)  {
        for (j = i+1; j < n ;j++) {
           if (A[i] == A[j]) printf("%d th data item = %d is repeated\n",i,A[i]);
           for ( ; j<n-1; j++)  A[j] = A[j+1] ;  // remove the repeated one.
           n --;
        }
    }
   printf("the data items are : ");
   for (i=0; i<n; i++)  printf("%d  ", A[i]);

}
1 5 1
click on thanks button above pls;;;select best answer