+ 1

Reverse a string words without using function

Ex Input:- hello world Output:- world hello

14th Jun 2020, 7:22 AM
Ashwini Borla
Ashwini Borla - avatar
4 Answers
+ 2
It's easy if you master indexing skills........like reverse indexing and use of loops also
14th Jun 2020, 7:34 AM
Abhijit
Abhijit - avatar
0
How can I make this print
14th Jun 2020, 7:24 AM
Ashwini Borla
Ashwini Borla - avatar
0
1) identify words or, in other words, index of start and end of current word in string 2) for any word, swap characters using a pivot index betwen start and end word Anyway, its better post your try so we can help you more
14th Jun 2020, 9:02 AM
KrOW
KrOW - avatar
- 1
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String text = scanner.nextLine(); char[] arr = text.toCharArray(); String reverse=""; for(int i=arr.length-1; i>=0; i--){ reverse=reverse+arr[i];} System.out.print(reverse); } }
11th Jan 2021, 5:05 PM
Its souhaib
Its souhaib - avatar