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 library is sizeof in c?

1084


is it possible to create your own header files?

1101


What is wrong with this program statement?

1031


Why enum is used in c?

949


What is the purpose of 'register' keyword?

1098


what are the 10 different models of writing an addition program in C language?

1892


What does char * * argv mean in c?

1053


ATM machine and railway reservation class/object diagram

5241


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

1308


Explain union.

1167


Explain the advantages of using macro in c language?

993


Why static is used in c?

1089


What is c standard library?

1201


Explain zero based addressing.

1019


How do we print only part of a string in c?

1020