0% found this document useful (0 votes)
14 views1 page

Exponentiation Program in Kotlin

This document contains a Kotlin program that calculates the exponent of a number x raised to the power of y. It prompts the user for input values of x and y, then computes the result based on the conditions for x and y. Finally, it prints the result along with a signature from the author.

Uploaded by

narong
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

Exponentiation Program in Kotlin

This document contains a Kotlin program that calculates the exponent of a number x raised to the power of y. It prompts the user for input values of x and y, then computes the result based on the conditions for x and y. Finally, it prints the result along with a signature from the author.

Uploaded by

narong
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

@file:JvmName("JDoodle")

fun main() {
println("Program Exponent x^y")
var x: Int
var y: Int
var z: Int
var i: Int = 2

print("Input X : ")
x = readln().toInt()
print("Input y : ")
y = readln().toInt()

if(x <=0){
z = 0
}
else{
if(y <=0){
z = 1
}
else if (y<=1){
z = x
}
else{
z = x
while(i <=y){
z = z * x
i++
}
}
}

println(" $x ^ $y = $z")
print("Code By Narong")
}

You might also like