#include<stdio.h>
#include<conio.h>
#include<malloc.h>
main()
{
int n,*arr,j,i,f=0;
printf("\n Enter the size of the array ");
scanf("%d",&n);
arr=(int*)malloc(n*2);
for(i=0;i<n;i++)
{
printf("\n Enter the element: %d ",i);
scanf("%d",(arr+i));
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(*(arr+i)==*(arr+j) && i!=j)
{
f=1;
printf("\n Duplicate number found at position %d and %d. ",i,j);
}
}
}
if(f==0)
printf("\n No duplicate number found..... ");
getch();
}
#include<conio.h>
#include<malloc.h>
main()
{
int n,*arr,j,i,f=0;
printf("\n Enter the size of the array ");
scanf("%d",&n);
arr=(int*)malloc(n*2);
for(i=0;i<n;i++)
{
printf("\n Enter the element: %d ",i);
scanf("%d",(arr+i));
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(*(arr+i)==*(arr+j) && i!=j)
{
f=1;
printf("\n Duplicate number found at position %d and %d. ",i,j);
}
}
}
if(f==0)
printf("\n No duplicate number found..... ");
getch();
}
No comments:
Post a Comment
Convey your thoughts to authors.