write a function that accepts an array A with n elements and
array B with n-1 elements. Find the missing one in array
B,with an optimized manner?
Answer Posted / vaibhav nigam
// missing number= diff in sum of 2 arrays
int missing_number(int A[], int B[], int n)
{
int sum1=0;
for(int i=0; i<n; i++) {
sum1+=A[i];
}
int sum2=0;
for(int i=0; i<n-1; i++) {
sum2+=B[i];
}
return (sum1-sum2);
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What are the types of assignment statements?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
What is the process of writing the null pointer?
What is wrong with this initialization?
What are identifiers and keywords in c?
What is c language and why we use it?
When was c language developed?
What is spaghetti programming?
For what purpose null pointer used?
write a program to rearrange the array such way that all even elements should come first and next come odd
What is optimization in c?
What is pass by value in c?
List the difference between a While & Do While loops?
Write a program on swapping (100, 50)
Explain how can I prevent another program from modifying part of a file that I am modifying?