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

Kotlin

Uploaded by

Nigar Qurbanova
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)
11 views1 page

Kotlin

Uploaded by

Nigar Qurbanova
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
You are on page 1/ 1

question1.

Find Factorial of a number using for loop.


answer:

fun main(args: Array<String>) {

val num = 10
var factorial: Long = 1
for (i in 1..num) {
// factorial = factorial * i;
factorial *= i.toLong()
}
println("Factorial of $num = $factorial")
}

question2.
Kotlin Program to Check Whether a Character is Alphabet or Not
answer:
fun main(args: Array<String>) {

val c = '*'

if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
println("$c is an alphabet.")
else
println("$c is not an alphabet.")
}

You might also like