WAP TO CHECK DUPLICACY OF ELEMENTS
IN A GIVEN LIST
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()
{
int a[100],
num,i,j,b=0;
clrscr();
cout<<"Enter the size of the list";
cin>>num;
cout<<"Enter the items in the list";
for(i=0;i<num;i++)
{
cin>>a[i];
}
for(i=0;i<num;i++)
{
for(j=i+1;j<num;j++)
{
if (a[i]==a[j])
{b=1;}
}
}
if (b==1)
cout<<"duplicacy is there";
else
cout<<"All elements in the list are unique";
getch();
}
No comments:
Post a Comment