# Day: May 5, 2021

## Kotlin example for Beginners – Kotlin Program to Display Prime Numbers Between Two Intervals

Hits: 7 Kotlin Program to Display Prime Numbers Between Two Intervals In this program, you’ll learn to display prime numbers between two given intervals, low and high. You’ll learn to do this using a while and a for loop in Kotlin. Example: Display Prime Numbers Between two Intervals fun main(args: Array<String>) { var low = …

## Kotlin example for Beginners – Kotlin Program to Check Whether a Number is Prime or Not

Hits: 2 Kotlin Program to Check Whether a Number is Prime or Not In this article, you’ll learn to check whether a number is prime or not. This is done using a for-in loop in Kotlin. Example 1: Program to Check Prime Number using a for-in loop fun main(args: Array<String>) { val num = 29 …

## Kotlin example for Beginners – Kotlin Program to Calculate the Power of a Number

Hits: 14 Kotlin Program to Calculate the Power of a Number In this program, you’ll learn to calculate the power of a number with and without using pow() function. Example 1: Calculate power of a number without using pow() fun main(args: Array<String>) { val base = 3 var exponent = 4 var result: Long = …

## Kotlin example for Beginners – Kotlin Program to Calculate the Power of a Number

Hits: 5 Kotlin Program to Calculate the Power of a Number In this program, you’ll learn to calculate the power of a number with and without using pow() function. Example 1: Calculate power of a number without using pow() fun main(args: Array<String>) { val base = 3 var exponent = 4 var result: Long = …

## Kotlin example for Beginners – Kotlin Program to Display Characters from A to Z using loop

Hits: 1 Kotlin Program to Display Characters from A to Z using loop In this program, you’ll learn to print English alphabets using while loop in Kotlin. You’ll also learn learn to print only uppercased and lowercased alphabets. Example 1: Display Uppercased A to Z fun main(args: Array<String>) { var c: Char c = ‘A’ …

## Kotlin example for Beginners – Kotlin Program to Find GCD of two Numbers

Hits: 3 Kotlin Program to Find GCD of two Numbers In this program, you’ll learn to find GCD of two numbers in Kotlin. This is done by using while loop with the help of if else statement. The HCF or GCD of two integers is the largest integer that can exactly divide both numbers (without …

## Kotlin example for Beginners – Kotlin Program to Display Fibonacci Series

Hits: 3 Kotlin Program to Display Fibonacci Series In this program, you’ll learn to display fibonacci series in Kotlin using for and while loops. You’ll learn to display the series upto a specific term or a number. The Fibonacci series is a series where the next term is the sum of pervious two terms. The …

## Kotlin example for Beginners – Kotlin Program to Generate Multiplication Table

Hits: 0 Kotlin Program to Generate Multiplication Table In this program, you’ll learn to generate multiplication table of a given number. This is done by using a for and a while loop in Kotlin. You’ll also learn to use ranges to solve the problem. Example 1: Generate Multiplication Table using for loop fun main(args: Array<String>) …

## Kotlin example for Beginners – Kotlin Program to Find Factorial of a Number

Hits: 0 Kotlin Program to Find Factorial of a Number In this program, you’ll learn to find the factorial of a number using for and while loop in Kotlin. You’ll also learn to use ranges to solve this problem. The factorial of a positive number n is given by: factorial of n (n!) = 1 * 2 …

## Kotlin example for Beginners – Kotlin Program to Calculate the Sum of Natural Numbers

Hits: 1 Kotlin Program to Calculate the Sum of Natural Numbers In this program, you’ll learn to calculate the sum of natural numbers using for loop and while loop in Kotlin. You’ll also see how ranges can be helpful for solving the problem. The positive numbers 1, 2, 3… are known as natural numbers and …

## Kotlin example for Beginners – Kotlin Program to Check Whether a Character is Alphabet or Not

Hits: 4 Kotlin Program to Check Whether a Character is Alphabet or Not In this program, you’ll learn to check whether a given character is an alphabet or not. This is done using an if else statement or when expression in Kotlin. Example 1: Kotlin Program to Check Alphabet using if else fun main(args: Array<String>) …

## Kotlin example for Beginners – Kotlin Program to Check Leap Year

Hits: 3 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). …

## Kotlin example for Beginners – Kotlin Program to Add Two Integers

Hits: 4 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 …

## Kotlin example for Beginners – Kotlin Program to Check Whether an Alphabet is Vowel or Consonant

Hits: 0 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 …

## Kotlin example for Beginners – Kotlin Program to Check Whether a Number is Even or Odd

Hits: 2 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 …

## Kotlin example for Beginners – Kotlin Program to Swap Two Numbers

Hits: 3 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 …