[CSI] Question about CS1A final exam example...

Mikhail Nesterenko mikhail at cs.kent.edu
Tue Oct 18 15:42:07 EDT 2016


> For number 1, would the answer be "hi" or "hello"?
> I had trouble following in class on Monday when you explained this part.

In the conditional assignment, s3 is assigned the lesser of s1 and
s2. s2 is less than s1 because the strings are compared
lexicographically (dictionary order): by the first letter that is
different in the two strings. The different letters are "e" and
"i". "e" is less than "i", because "e" goes before "i" in the
alphabet.  Hence, "Hello" < "Hi"

Thanks,
--
Mikhail


More information about the cs13001 mailing list