Assume that s is a string. Write an expression whose value is true if and only i
ID: 3653750 • Letter: A
Question
Assume that s is a string. Write an expression whose value is true if and only if the value of s would come between "mortage and "mortuary" in the dictionary.Explanation / Answer
(strcmp(s, "mortgage") > 0) && (strcmp(s, mortuary) < 0) The pattern for comparing C strings in C or C++ is to convert the string1 string2 ...comparison that you'd like to do into strcmp(string1,string2) 0, ...where is any comparison operator, =, !=, etc. You need to include to get the prototype for strcmp (or include in C). For C++ string variables (std::string class), use: (s.compare("mortgage") > 0) && (s.compare("mortuary") < 0)Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.