1.

Write a user-defined function EXTRA_ELE(int A[ ], int B[ ], int N) in C++ to find and display the extra element in Array A. Array A contains all the elements of array B but one more element extra. (Restriction: array elements are not in order)Example If the elements of Array A is 14, 21, 5, 19, 8, 4, 23, 11and the elements of Array B is 23, 8, 19, 4, 14, 11, 5Then output will be 21

Answer»

void EXTRA_ELE(int A[], int B[],int N)

{

int i,j,flag=0;

for(i=0;i<N;i++)

{

for(j=0;j<N;j++)

{

if(A[i]==B[j])

{

flag=1;

break;

}

}

if(flag==0)

cout<<"Extra element"<<A[i];

flag=0;

}

}



Discussion

No Comment Found

Related InterviewSolutions