Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the types of assignment statements?

1019


the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?

959


What is the process of writing the null pointer?

990


What is wrong with this initialization?

963


What are identifiers and keywords in c?

1045


What is c language and why we use it?

1014


When was c language developed?

1145


What is spaghetti programming?

1084


For what purpose null pointer used?

1023


write a program to rearrange the array such way that all even elements should come first and next come odd

2239


What is optimization in c?

958


What is pass by value in c?

1022


List the difference between a While & Do While loops?

1057


Write a program on swapping (100, 50)

1074


Explain how can I prevent another program from modifying part of a file that I am modifying?

1046