if array a conatins 'n' elements and array b conatins 'n-1'
elements.array b has all element which are present in array
a but one element is missing in array b. find that
element.

Answer Posted / venu

use XOR association operation.
I mean: a = b^a^b = a^b^b = a;[bec a^a =0 always]

int main()
{
int a[3] = {3,4,5};
int b[4] = {7,4,5,3};
int r,i;
int n=4;

r1 = b[3];

for(i=0;i<n-1;i++)
{
r1 = r1^a[i]^b[i];
}

printf("number = %d \n",r);
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When should you use a type cast?

589


What is #include called?

566


string reverse using recursion

1809


Are there constructors in c?

591


What are the 32 keywords in c?

632






Why we use stdio h in c?

575


How can I manipulate strings of multibyte characters?

635


What are the types of data files?

729


What is the difference between array and pointer?

567


When should a far pointer be used?

602


How will you find a duplicate number in a array without negating the nos ?

1642


What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers

675


What are the advantages of Macro over function?

1195


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

668


What is LINKED LIST? How can you access the last element in a linked list?

631