Advertisement
Nafiz_Ahmed

Untitled

Jul 22nd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a[100], f[100];
  5. int size,i,j,count,sum;
  6. printf("Enter size of array: ");
  7. scanf("%d", &size);
  8. printf("Enter elements of the array:");
  9. for(i=0; i<size; i++)
  10. {
  11. scanf("%d", &a[i]);
  12. f[i] =a[i];
  13. }
  14. for(i=0; i<size; i++)
  15. {
  16. count=0;
  17. for(j=i+1; j<size; j++)
  18. {
  19. if(a[i]==a[j])
  20. {
  21. count++;
  22. f[j]=0;
  23. f[i]=count;
  24. break;
  25. }
  26.  
  27. }
  28. }
  29. printf("Total number of duplicate elements = ");
  30. for(i=0; i<size; i++)
  31. { if(f[i]==1){
  32. sum=sum+f[i];
  33. }
  34.  
  35. }
  36. printf("%d\n",sum);
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement