adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C to Find duplicate number in given array and delete.

Program in C to Find duplicate number in given array and delete



#include<stdio.h>
#include<conio.h>
  void main()
     {
     int i,a[5],l,c=1,j,d;
     clrscr();
     printf("Enter 5 numbers:-");
     for(i=0;i<=4;i++)
     scanf("%d",&a[i]);
     for(i=0;i<=4;i++)
      {
        for(j=1+i;j<=4;j++)
        {
         if(a[i]==a[j])
         {
            c++;
            l=a[i];
            break;
          }
        }
      }
      if(c>=2)
           printf("%d is duplicate no.",l);
      else
          printf("Not any number is duplicate.");
       //after delete duplicate numbers
       printf("\nNew array is ");
    for(i=0;i<5;i++)
     {
       if(a[i]==l)
             continue;
       else
           printf("%3d",a[i]);
     }
   getch();
  }
Output:-
             




Post a Comment

0 Comments