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
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 |
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 |
How can I avoid the abort, retry, fail messages?
write a program which counts a product of array elements lower than 10.
What is the use of getchar functions?
Tell me what are bitwise shift operators?
What is structure in c explain with example?
Explain how can I remove the trailing spaces from a string?
the output will be #include<stdio.h> int main () { int i; i = 9/2; printf("%i",i); return 0; }
Why do we need volatile in c?
How does pointer work in c?
In which header file is the null macro defined?
here is a link to download Let_Us_C_-_Yashwant_Kanetkar
When should a far pointer be used?