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

Is it better to use a macro or a function?

0 Answers  


struct tag{ auto int x; static int y; };main() { struct tag s; s.x=4; s.y=5; printf(ā€œ%dā€,s.x); }

2 Answers   Vector,


What is the difference between printf and scanf in c?

0 Answers  


What is a file descriptor in c?

0 Answers  


Synonymous with pointer array a) character array b) ragged array c) multiple array d) none

0 Answers  






How many parameters should a function have?

0 Answers  


What will happen when freeing memory twice

2 Answers  


What is a struct c#?

0 Answers  


What is the role of this pointer?

0 Answers  


What is structure and union in c?

0 Answers  


What are formal parameters?

0 Answers  


What is the difference between null pointer and void pointer

10 Answers   CTS, Manforce, MAQ Software,


Categories