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, 11 and the elements of Array B is 23, 8, 19, 4, 14, 11, 5 Then output will be 21
Answers
Answered by
12
The function is as follows:
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(lag==0)
count<<"extra element"<<A[i];
flag=0;
}
}
Like this N displays 3,15,6,18,12,9.
Similar questions