sandeep kumar tiwari


{ City } pratapgarh
< Country > india
* Profession * java
User No # 69898
Total Questions Posted # 0
Total Answers Posted # 1

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 9
Users Marked my Answers as Wrong # 4
Questions / { sandeep kumar tiwari }
Questions Answers Category Views Company eMail




Answers / { sandeep kumar tiwari }

Question { TCS, 35175 }

Write, efficient code for extracting unique elements from
a sorted list of array.

e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).


Answer

void main()
{
int i,j;
int a[11]={1,1,3,3,3,5,5,5,9,9,9,9};
clrscr();
i=a[0];
printf("%d",i);

for(j=1;j<11;j++)
{
if(a[j]!=a[i])
{
if(a[j-1]==a[j])
continue;
else
printf("%d",a[j]);
i=j;
}
}
getch();
}
}

Is This Answer Correct ?    9 Yes 4 No