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’s a signal? Explain what do I use signals for?
Differentiate between the = symbol and == symbol?
Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings
How does placing some code lines between the comment symbol help in debugging the code?
What are directives in c?
how to create duplicate link list using C???
What are valid operations on pointers?
Is c weakly typed?
Why main function is special give two reasons?
what are the advantages of a macro over a function?
What is null in c?
Is it possible to use curly brackets ({}) to enclose single line code in c program?
What are the types of assignment statements?
What is keyword in c?
Can the sizeof operator be used to tell the size of an array passed to a function?