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?

Answers were Sorted based on User's Feedback



write a function that accepts an array A with n elements and array B with n-1 elements. Find the mi..

Answer / 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

write a function that accepts an array A with n elements and array B with n-1 elements. Find the mi..

Answer / aravind

#include<stdio.h>
int missing_item(int,int);
int main()
{
int a[10];
int b[9];
printf("enter size of array");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter the elemets of array a ");
scanf("%d",&a);
}

for(i=0;i<n-1;i++)
{
printf("enter b elements");
scanf("%d",&b);
missing_item(int c,int d)
{
int item;
for(i=0;i<n;i++)
{
if(c[i]==d[i])
break;
else
{
item=c[i];
printf("the missing item is=%d",c[i]);
}

}

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C Interview Questions

Which one would you prefer - a macro or a function?

0 Answers  


I need previous papers of CSC.......plz help out by posting them.......

0 Answers  


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

5 Answers   TCS, Vimukti Technologies,


What is nested structure in c?

0 Answers  


In the following code segment what will be the result of the function, value of x , value of y { unsigned int x=-1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); } a) same, MAXINT, -1 b) not same, MAXINT, -MAXINT c) same , MAXUNIT, -1 d) same, MAXUNIT, MAXUNIT e) not same, MAXINT, MAXUNIT

1 Answers   IBM,






What will be your course of action for a push operation?

0 Answers  


Program to simulate second clock

2 Answers  


How can I make sure that my program is the only one accessing a file?

0 Answers  


write a program that will accept two integers and will implement division without using the division operator if the second value is an odd number and will implement multiplication without using multiplication operator if the second value is an even number.

1 Answers  


Define recursion in c.

0 Answers  


What is a newline escape sequence?

0 Answers  


who did come first hen or agg

15 Answers   Infosys,


Categories