Calculate square and square root of a number

Report a typo

Write a Kotlin program that calculates the square and the square root of a given integer. The input will be the integer to process. The output should be a string in the format 'Square: X, Square root: Y'.

Sample Input 1:

5

Sample Output 1:

Square: 25, Square root: 2.23606797749979

Sample Input 2:

9

Sample Output 2:

Square: 81, Square root: 3.0
Write a program in Kotlin
// Importing required library
import kotlin.math.sqrt

fun main(args: Array<String>) {
// Reading the integer from user
val input = readLine()!!.toInt()

// Perform the arithmetic operations on 'input' here

// Prepare the output in required format and print it
val result =
println(result)
}

Create a free account to access the full topic