

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A C++ code that defines a function to reverse a C-string (an array of char) using a for loop that swaps the first and last characters, then the second and next-to-last character and so on. The code also includes a main function that gets a string from the user, calls the reverse function and displays the reversed string. the full code and comments explaining each step.
Typology: Lab Reports
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Lab Task 11.1 Write a function reverse() that reverses a C-string (an array of char). Use a for loop that swaps the first and last characters, then the second and next-to-last character and so on. Pass a string from main() to reverse() as an argument to reverse it. #include
Lab Task 11.2 Write a function compare() that will take two strings as arguments from main(). Compare these two strings whether they are equal or one is equal than other.