1. ## programming assignment help

Ok, I was assigned to do certain exercises out of my programming book for my class, I am having a bit of trouble and would appreciate some help. Here's the question:

"Let f be the following function:
Code:
```int f(char *s, char *t)
{
char *p1, *p2;

for (p1 = s; *p1; p1++)  {
for (p2 = t; *p2; p2++)
if (*p1 == *p2) break;
if (*p2 == '\0') break;
}
return p1-s;
}```
(a) What is the value of f ( "abcd" , "babc") ?
(b) What is the value of f ( "abcd" , "bcd") ?
(c) In general, what values does f return when passed two strings s and t?"

I put this code in a program and ran it myself. I may have did it wrong but for (a) I got 3 and for (b) I got 0. I don't really understand what is going on here and I would appreciate if someone could explain (c) to me.

2. IT is finding the first charcter in s which is not present in t and returning its position

3. ok, thank you. I still don't understand how it is doing that but I will keep trying to figure it out. thanks for the help tho.

4. Code:
```int f(char *s, char *t)
{
char *p1, *p2;

for (p1 = s; *p1; p1++)  {
for (p2 = t; *p2; p2++)
{ if (*p1 == *p2) break;
}
if (*p2 == '\0') break;
}
return p1-s;
}```
may be this will clear the code to you.it will find the last character in s that is different in t.sorry for the mistake in previous reply.
the inner for loop is running untill the value is equal the first for loop is incremented....