Machine Problem

Write a C program to remove all duplicate numbers from an array.      It will only display unique numbers on screen after the deletion of all duplicate numbers from an array.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGgThank you very much for your support

Program Listing

#include <stdio.h>
  
 /* 
    Machine Problem
    Write a C program to remove all duplicate numbers from an array.
    It will only display unique numbers on screen after the deletion 
	of all duplicate numbers from an array.
	*/
    
int main() {
   int arr[100], i=0;
   int j=0, k=0,items=0;
 
   printf("\n");
   printf("\tRemove Duplicate Numbers From An Array in C");
   printf("\n\n");
   printf("\tHow Many Items? : ");
   scanf("%d",&items);
 
   printf("\n");
   for (i = 0; i < items; i++) {
   	    printf("\tEnter Value in Item No. % : ",i+1);
		scanf("%d", &arr[i]);
   }
     
   printf("\n");
   printf("\tList of Numbers That Are Not Duplicate ");
   printf("\n\n");
   for (i = 0; i < items; i++) {
      for (j = i + 1; j < items;) {
         if (arr[j] == arr[i]) {
            for (k = j; k < items; k++) {
               arr[k] = arr[k + 1];
            }
            items--;
         } else
            j++;
      }
   }
   printf("\n");
   printf("\t");
   for (i = 0; i < items; i++) {
      printf("%d ", arr[i]);
   }
    printf("\n\n");
   printf("\tEnd of Program");
   printf("\n");
   return 0;
}

Leave a Reply

Your email address will not be published.