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 library is sizeof in c?
is it possible to create your own header files?
What is wrong with this program statement?
Why enum is used in c?
What is the purpose of 'register' keyword?
what are the 10 different models of writing an addition program in C language?
What does char * * argv mean in c?
ATM machine and railway reservation class/object diagram
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
Explain union.
Explain the advantages of using macro in c language?
Why static is used in c?
What is c standard library?
Explain zero based addressing.
How do we print only part of a string in c?