Write a program with three functions: upper , lower , and reverse . The upper function should accept a pointer to a C-string as an argument. It should step through each character in the string, converting it to uppercase. The lower function, too, should accept a pointer to a C-string as an argument. It should step through each character in the string, converting it to lowercase. Like upper and lower , reverse should also accept a pointer to a string. As it steps through the string, it should test each character to determine whether it is upper- or lowercase. If a character is uppercase, it should be converted to lowercase. Likewise, if a character is lowercase, it should be converted to uppercase. Test the functions by asking for a string in function main , then passing it to them in the following order: reverse , lower , and upper .
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
If you’re looking for a quick way to generate C++ code for this, you can try DigitalOcean’s GenAI Platform! 🚀
With DigitalOcean GenAI, you can spin up your own AI agent and have it generate, test, and refine your C++ code instantly. Just describe the problem, and the AI will generate the functions for you—no need to wait for a response.
Give it a shot and let me know how it works for you! 😃
- Bobby
Heya,
You can use the DigitalOcean AI product for AI-driven code assistance and automation. Check it out here : DigitalOcean Gen AI.
As for answering your question. Below is the C++ program implementing the
upper
,lower
, andreverse
functions: