196k views
4 votes
Given string strInput1 on one line and string strInput2 on a second line, assign longerStr with the longer string. If the strings are the same length, assign longerStr with "Same Length".

Ex: If the input is:

ornament
rice

then the output is:

ornament

User Tom Porat
by
7.4k points

1 Answer

3 votes
If (strInput1.length > strInput2.length){
longerStr = strInput1;
} else if (strInput1.length < strInput2.length) {
longerStr = strInput2;
} else {
longerStr = “Same Length”;
}
User Talendar
by
7.9k points