# Category: Kotlin Examples

python tutorials and learn python

### Kotlin Program to Check Leap Year

Kotlin Program to Check Leap Year In this program, you’ll learn to check if the given year is a leap year or not in Kotlin. This is checked using a if else statement and a when statement. A leap year is exactly divisible by 4 except for century years (years ending with 00). The century…

### Kotlin Program to Find all Roots of a Quadratic Equation

Kotlin Program to Find all Roots of a Quadratic Equation In this program, you’ll learn to find all roots of a quadratic equation (depending upon the determinant) and print them using format() in Kotlin. The standard form of a quadratic equation is: ax2 + bx + c = 0, where a, b and c are…

### Kotlin Program to Find the Largest Among Three Numbers

Kotlin Program to Find the Largest Among Three Numbers In this program, you’ll learn to find the largest among three numbers using if else and when statement in Kotlin. Example 1: Find Largest Among three numbers using if..else statement fun main(args: Array<String>) { val n1 = -4.5 val n2 = 3.9 val n3 = 2.5…

### Kotlin Program to Check Whether an Alphabet is Vowel or Consonant

Kotlin Program to Check Whether an Alphabet is Vowel or Consonant In this program, you’ll learn to check whether an alphabet is a vowel or a consotant using if..else and when statement in Kotlin. Example 1: Check whether an alphabet is vowel or consonant using if..else statement fun main(args: Array<String>) { val ch = ‘i’…

### Kotlin Program to Check Whether a Number is Even or Odd

Kotlin Program to Check Whether a Number is Even or Odd In this program, you’ll learn to check if a number entered by an user is even or odd. This will be done using two variants of if…else in Kotlin. Example 1: Check whether a number is even or odd using if…else statement import java.util.*…

### Kotlin Program to Swap Two Numbers

Kotlin Program to Swap Two Numbers In this program, you’ll learn two techniques to swap two numbers in Kotlin. The first one uses a temporary variable for swapping, while the second one doesn’t use any temporary variables. Example 1: Swap two numbers using temporary variable fun main(args: Array<String>) { var first = 1.20f var second…

### Kotlin Program to Compute Quotient and Remainder

Kotlin Program to Compute Quotient and Remainder In this program, you’ll learn to compute quotient and remainder from the given dividend and divisor in Kotlin. Example: Compute Quotient and Remainder fun main(args: Array<String>) { val dividend = 25 val divisor = 4 val quotient = dividend / divisor val remainder = dividend % divisor println(“Quotient…

### Kotlin Program to Find ASCII value of a character

Kotlin Program to Find ASCII value of a character In this program, you’ll learn to find and display the ASCII value of a character in Kotlin. This is done using type-casting and normal variable assignment operations. Example: Find ASCII value of a character fun main(args: Array) { val c = ‘a’ val ascii = c.toInt()…