Reverse a user-input string

Report a typo

Write a program in Kotlin that reads a string and returns the reversed version of that string. Your program should interactively ask the user for a single string and should display the reversed string as the output.

Sample Input 1:

Hello

Sample Output 1:

olleH

Sample Input 2:

Kotlin

Sample Output 2:

niltoK
Write a program in Kotlin
import java.util.Scanner // Required for reading user input.

fun main(args: Array<String>) {
// Create a scanner object for reading user input.
val scanner = Scanner(System.`in`)

// Read a line of input from the user.
val inputString = scanner.nextLine()

// Call your function here to reverse the inputString.
// Print the reversed string.
}

Create a free account to access the full topic