C Program- To remove duplicate integer from an array

Posted: January 14, 2012 in Lab 1
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *input,*output,n,i,temp='\0';
printf("Enter nos. you want to enter\n");
scanf("%d",&n);
input=(int *)malloc(n*sizeof(int));
output=(int *)calloc(n,sizeof(int));
for(i=0;i<n;i++)
{
scanf("%d",(input+i));
}
for(i=0;i<n;i++)
{
*(output+*(input+i))=*(input+i);
}
for(i=0;i<n;i++)
{
if(*(input+i)==temp)
continue;
temp=*(input+i);
printf("%d\n",*(output+*(input+i)));
}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s