Tuesday, 5 March 2013

Program to detect duplicacy and remove duplicate value


By on 02:40

Program to detect duplicacy and remove duplicate value:-


Q)Write a program to create array and print the array without duplicacy.

Note:-You can also create this program in c++(c plus plus),java,c#(c sharp) languages with the same logic.


P:#include<stdio.h>
Void main()
{
int i,lim,a[50],p,q;
printf("enter limit");
scanf("%d",&l);
printf("Enter Array");
for(i=0;i<lim;i++)
scanf("%d",&a[i]);
for(i=0;i<lim-1;i++)
{
for(p=i+1;p<lim;p++)
{
if(a[i]==a[p])
{
for(q=p;q<lim-1;q++)
a[q]=a[q+1];
lim--;
p--;
}
}
}
printf("Array as follows");
for(i=0;i<lim;i++)
printf("%d",a[i]);
getch();
}

If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...