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

Given a string write a program to print all alphabetical characters in the order of their occurance first,followed by the sum of the numeric characters then followed by the special characters in the order of their occurance.

1 Answers   College School Exams Tests, Wipro,


whenever a question is posted in a particular category in allinterview.com, Is there any facility to receive an indication mail. For eg: I need to receive an indication email, whenever a question is posted under the category “C Langauage”.

1 Answers  


here is a link to download Let_Us_C_-_Yashwant_Kanetkar

3 Answers   Microsoft,


change to postfix a/(b+c*d-e)

8 Answers   Value Labs,


What does typedef struct mean?

0 Answers  


Do you know the use of fflush() function?

0 Answers  


What is #include stdio h and #include conio h?

0 Answers  


Explain what does it mean when a pointer is used in an if statement?

0 Answers  


Write a program to generate prime factors of a given integer?

9 Answers   Microsoft,


How can we open a file in Binary mode and Text mode?what is the difference?

1 Answers   PanTerra,


write an interactive C program that will encode or decode a line of text.To encode a line of text,proceed as follows. 1.convert each character,including blank spaces,to its ASCII equivalent. 2.Generate a positive random integer.add this integer to the ASCII equivalent of each character.The same random integer will be used for the entire line of text. 3.Suppose that N1 represents the lowest permissible value in the ASCII code,and N2 represents the highest permissible value.If the number obtained in step 2 above(i.e.,the original ASCII equivalent plus the random integer)exceeds N2,then subtract the largest possible multiple of N2 from this number,and add the remainder to N1.Hence the encoded number will always fall between N1 and N2,and will therefore always represent some ASCII character. 4.Dislay the characters that correspond to the encoded ASCII values.  The procedure is reversed when decoding a line of text.Be certain,however,that the same random number is used in decodingas was used in encoding.

0 Answers  


I have a varargs function which accepts a float parameter?

0 Answers  


Categories