Question: B- Develop a C method that, given a String s, returns the reverse of s. Let cOclc2...cn be a string, where each ci is a

B- Develop a C method that, given a String s, returns the reverse of s. Let cOclc2...cn be a string, where each ci is a character. Then its reverse is cncn-1...c2clco Notice that the first character of the reverse is the last character of the original and that what follows it is the reverse of the string obtained by chopping off the last character of the original string. Combining this with the observation that the reverse of the empty string is itself, we surmise that if s has length zero reverse(s) = a +reverse(s) otherwise where + denotes concatenation, s' denotes s with its last character chopped off, and a denotes the last character of s. 2.5 Marks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
