Because I am finding the element in the range of 0 to 4 , total 5 elements And the loop is iterating for the interval of 0 - 3 , so to XOR 4 also (last index) . I have done that . Got it /????
On Jul 18, 3:02 pm, sagar pareek <sagarpar...@gmail.com> wrote: > @SAMM > please explain why u are using res^=j; ? > i m not good in bits operations... > > > > > > On Mon, Jul 18, 2011 at 1:24 PM, SAMMM <somnath.nit...@gmail.com> wrote: > > /* > > INPUT:- > > 5 --> NO of testr cases > > 0 > > 1 > > 4 > > 5 > > 3 > > OUTPUT:- > > 2 > > */ > > > #include<stdio.h> > > #include<stdlib.h> > > int main() > > { > > int n=0,j=0,t=0,res; > > res=0L; > > scanf("%d",&t); > > while(t--) > > { > > scanf("%d",&n); > > res^=n;res^=j; > > j++; > > } > > printf("%d\n",res^j); > > return 0; > > } > > > Example :-- > > 4 > > 0 > > 4 > > 1 > > 3 > > > Output:- > > 2 (Because the in the list 0 to 4 , element 2 is missing ) > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to algogeeks@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. > > -- > **Regards > SAGAR PAREEK > COMPUTER SCIENCE AND ENGINEERING > NIT ALLAHABAD- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.