if array a conatins 'n' elements and array b conatins 'n-1'
elements.array b has all element which are present in array
a but one element is missing in array b. find that
element.

Answer Posted / furquan

@Rasika : It will work even for array of characters i.e.
string. It will calculate on the ascii value.

int main()
{
char a[] = "abcghs", b[] = "abchs";
int sum = 0,i;

int n = strlen(a);
for (i=0;i<n-1;i++){
sum += a[i] - b[i];
}
sum += a[i];

printf("%c\n",sum);
return 0;
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is struct padding needed?

834


What is the use of extern in c?

857


What is wrong with this declaration?

852


Write a simple code fragment that will check if a number is positive or negative.

926


What is volatile variable how do you declare it?

790


typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none

990


Why is sprintf unsafe?

825


what is the difference between class and unio?

2122


What is static function in c?

862


What’s a signal? Explain what do I use signals for?

871


A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.

1489


Is int a keyword in c?

746


Can a function argument have default value?

922


Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?

840


How do you list a file’s date and time?

832