Category: Kotlin Examples

python tutorials and learn python

Created with Sketch.

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…
Read more

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…
Read more

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…
Read more

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’…
Read more

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.*…
Read more

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…
Read more

Kotlin Program to Compute Quotient and Remainder

Computing Quotient and Remainder in Kotlin: A Comprehensive Guide In this blog post, we’ll explore the concept of computing the quotient and remainder in Kotlin. Understanding how to obtain these values from a division operation is fundamental to various programming scenarios. We’ll provide a Kotlin program that calculates both the quotient and remainder and delve…
Read more

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()…
Read more

Kotlin Program to Multiply two Floating Point Numbers

Kotlin Program: Multiply Two Floating Point Numbers In this blog post, we’ll explore a Kotlin program that multiplies two floating-point numbers. We’ll discuss the algorithm, provide a step-by-step explanation, present the Kotlin code, and include examples with outputs. Understanding the Algorithm The algorithm for multiplying two floating-point numbers involves the following steps: Input Numbers: Take…
Read more

Kotlin Program to Multiply two Floating Point Numbers

Kotlin Program to Multiply two Floating Point Numbers In this program, you’ll learn to multiply two floating point numbers in Kotlin, store the result and display it on the screen. Example: Multiply Two Floating Point Numbers fun main(args: Array<String>) { val first = 1.5f val second = 2.0f val product = first * second println(“The…
Read more