Kotlin Program to Check Whether an Alphabet is Vowel or Consonant

In this post, we will learn how to write a Kotlin Program to check whether an alphabet is a vowel or a consonant.

Kotlin Program to Check Whether an Alphabet is Vowel or Consonant

package com.kotlin.programs

fun main(args: Array < String > ) {

    val ch = 'a'
    val vowelConsonant =
        if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
            "vowel"
        } else {
            "consonant"
        }
    println("$ch is $vowelConsonant")
}
Output:
a is vowel



Comments