Reverse string | Sololearn: Learn to code for FREE!

+6

Reverse string

Hello Everyone, please! How can I reverse a string using c++

8/4/2020 5:56:16 AM

I-K(***)Y {99}

10 Answers

New Answer

+7

What have you tried so far and where you are stuck? Develop programming logic, just completing your course will not help. Do you know how to print a string char by char using loops? If yes then the process is same you just need to start from last char and process(print) till you reach the first char. This will show the string in reverse. If you actually want to modify the original string then append chars from the back to an empty string, then display the new string.

+4

Thank you so much! I'll try to understand it before using it. πŸ‘

+3

https://code.sololearn.com/c43od4mkBd4k/?ref=app

+3

https://code.sololearn.com/cLI6XKV2914t/?ref=app

+3

+2

You can have a look to the code playground in think there areany such programs πŸ˜…

+2

Here's my version in Python, but I'm a beginner in c++

+2

But you have completed more than 3/4 of C++ course. You have already covered enough C++ that needs to be used here. Try converting your python program in C++. You are already lacking some C++ coding practice, this is a good opportunity to write a C++ code. Give it a shot.

+1

just using without any predef functions https://code.sololearn.com/cCdZXXcyxVYk/?ref=app

+1

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String a = scanner.nextLine(); String b = new StringBuilder(a).reverse().toString(); System.out.println(b); } }