how find that with two comparisons
??
Printable View
how find that with two comparisons
??
edit
like this?
Code:if(strcmp(f1,f2)>0)
{
if (strcmp(f2,f3)>0)
smallest is f3
}
else
{
if (strcmp(f1,f3)>0)
smallest is f3
}
Yes, you are getting closer, but you are not there yet. Think about the cases where f1 and f2 are the smallest.
but still in the inner if i could get <0
so there i need to add another else
which is the same if
like this?Code:if(strcmp(f1,f2)>0)
{
if(strcmp(f2,f3)>0)
{
return f3;
}
else
{
return f2
}
}
else
{
if(strcmp(f1,f3)>0)
{
return f3;
}
else
{
return f1
}
}
Yes, but don't just take my word for it: test it yourself.