CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C DETAILS
Question :
How to remove duplicate elements from an array


Category C Interview Questions
Rating (0.0) By 0 users
Added on 7/18/2006
Views 1182
Rate it!
Answers:

#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
//abcd are occurs two times in an array f[30]
char f[30]={"abcdabcd"},name[30];
int i,j,m,n;
clrscr();
m=strlen(f);
n=m;
for(i=0;i<n;i++)
for(j=i+1;j<m;j++)
if(f[i]==f[j])
{
f[j]='$';
}
j=0;
printf("name=%s",f);
for(i=0;i<m;i++)
{
if(f[i]!='$')
{
name[j]=f[i];
j++;
}
}name[j]='



int main()
{
//2 and 3 are repeating
int a[10] = {1,2,3,2,4,5,6,3,2,3};
int i,j;
for(i=0;i<9;i++)
{
for(j=i+1;j<10;j++)
{
if(a[i] == a[j])
a[j] = 0;//Make the duplicate as 0;
}
}



 Posted by: vikas kumar shakya    

Contact vikas kumar shakya  Contact vikas kumar shakya


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
main(int x).............

explaination on arguments passed thr' main

View Answer
How do you write a C program which can calculate lines of code but not counting comments?

View Answer
How to swap the content of two variables without a temporary variable

View Answer
Output of this Programme please??

main()
{

int a[]={2,4,6,8,10};
int i;
change(a,5);
for(int i=0;i<=4;i++)
printf(" %d", a[i]);
}

change(int *b,int n)
{

int i;
for(i=0;i *(b+i) = *(b+i)+5;
}

sytaxis correct?? was asked i a test


View Answer
Can we use string in switch statement?

View Answer
How can you calculate number of nodes in a circular Linked List?

View Answer
What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?

View Answer
Where are the auto variables stored? What is the use of register variables?

View Answer
c program for delete a node from linked list


View Answer
What is the differece between #define and constant in C?

View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/5963/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.98