Skip to content

Check Vowel

Updated: at 09:36 AM

Table of contents

Open Table of contents

Write a program to check vowel

Vowel check is a simple program to check whether a character is a vowel or not.

Input  : a
Output : Vowel

C

// Write a C program to check vowel

#include <stdio.h>

int main(){

    char ch;
    scanf("%c",&ch);
    if(ch=='a' || ch=='A' || ch=='e' || ch=='E' || ch=='i' || ch=='I' || ch=='o' || ch=='O' || ch=='u' || ch=='U') printf("Vowel");
    else printf("Not Vowel");
    return 0;
}

//Contributed by Raghav Garg

C#

// Write a C# program to check vowel

using System;

public class vowelChar
{
    static void Main(string[] args)
    {
        char ch;

        Console.WriteLine("Enter any character: ");
        ch = Convert.ToChar(Console.ReadLine());

        if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')
        {
            Console.WriteLine(ch + " is a Vowel.");
        }
        else
        {
            Console.WriteLine(ch + " is not a Vowel.");
        }
    }
}

C++

// Write a C++ program to check vowel

#include <iostream>
using namespace std;

int main(){

    char ch;
    cin>>ch;
    if(ch=='a' || ch=='A' || ch=='e' || ch=='E' || ch=='i' || ch=='I' || ch=='o' || ch=='O' || ch=='u' || ch=='U') cout<<("Vowel")<<'\n';
    else cout<<("Not Vowel")<<'\n';
    return 0;
}

//Contributed by Raghav Garg

Go

// Write a Go program to check vowel

package main

import "fmt"

func main() {
	var input string
	fmt.Printf("Enter Letter: ")
	fmt.Scan(&input)

	if (input == "a") || (input == "e") || (input == "i") || (input == "o") || (input == "u") || (input == "A") || (input == "E") || (input == "I") || (input == "O") || (input == "U"){
		fmt.Printf("%v is a vowel\n", input)
	} else {
		fmt.Printf("%v is NOT a vowel\n", input)
	}

}

Java

// Write a Java program to check vowel

import java.util.Scanner;

public class CheckVowel {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String letter = scanner.nextLine().toLowerCase();
        isVowel(letter);
        scanner.close();
    }

    public static void isVowel(String letter) {
        String vowels = "aeiou";
        if (vowels.contains(letter))
            System.out.println("Vowel");
        else
            System.out.println("Not a Vowel");

    }
}

JavaScript

// Write a JavaScript program to check vowel

function checkVowels(str) {
  let isVowel = "";
  if (
    str == "a" ||
    str == "e" ||
    str == "i" ||
    str == "o" ||
    str == "u" ||
    str == "A" ||
    str == "E" ||
    str == "I" ||
    str == "O" ||
    str == "U"
  ) {
    isVowel = "Vowel";
  } else {
    isVowel = "Is not a Vowel";
  }
  return isVowel;
}

console.log(checkVowels("U"));

Julia

# Write a Julia program to check vowel

function vowelOrConsonant(char)
    char = lowercase(char)
    if (char == 'a' || char == 'e' || char == 'i' || char == 'o' || char == 'u') println("Vowel");
    else
        println("Consonant");
    end
end
vowelOrConsonant('a');

Kotlin

// Write a Kotlin program to check vowel

fun main() {
    print("Enter String : ")
    println()
    var input = readLine()

    println("$input is " + CheckVowel(input!!.first()))

}

private fun CheckVowel(ch: Char): String {
    if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'){
        return "Vowel"
    }

    return "Not Vowel"
}

PHP

// Write a PHP program to check vowel

<?php
	$str = readline('Enter letter: ');

  if ($str == 'a'
  || $str == 'e'
  || $str == 'i'
  || $str == 'o'
  || $str == 'u'
  || $str == 'A'
  || $str == 'E'
  || $str == 'I'
  || $str == 'O'
  || $str == 'U') {
    echo 'Vowel';
  }
  else {
    echo 'Is not a Vowel';
  }
?>

Python

# Write a Python program to check vowel

ch = input()
if (
    ch == "a"
    or ch == "A"
    or ch == "e"
    or ch == "E"
    or ch == "i"
    or ch == "I"
    or ch == "o"
    or ch == "O"
    or ch == "u"
    or ch == "U"
):
    print("Vowel")
else:
    print("Not Vowel")
# Contributed by Raghav Garg

R

# Write a R program to check vowel

checkVowel = function(char){
    if(char %in% c('a', 'e', 'i', 'o', 'u','A','E','I','O','U'))
        print("Vowel")
    else
        print("Consonant")
}

checkVowel('a')
# Output
# Vowel

checkVowel('E')
# Output
# Vowel

Ruby

# Write a Ruby program to check vowel

#Author: suryapoojary0
#date: "13-10-2022"
puts "Input a letter in uppercase or smallcase"
crux = ["a", "e" , "i", "o", "u", "A", "E", "I", "O", "U"]

num = gets.strip

if crux.include?(num) then
        puts "Vowel"
else                                                    puts "Not a Vowel"
end

Scala

// Write a Scala program to check vowel

object HelloWorld {
	def main(args: Array[String]): Unit = {
	  val line = scala.io.StdIn.readChar();
	  val vowels: String = "AEIOUaeiou";
	  if(vowels.contains(line)) {
	    println("is a vowel");
	  } else {
	    println("is not a vowel")
	  }
	}
}

Swift

// Write a Swift program to check vowel

import Swift
import Foundation

var given = "a"

if ((given == "a")
    || (given == "e")
    || (given == "i")
    || (given == "o")
    || (given == "u")
    || (given == "A")
    || (given == "E")
    || (given == "I")
    || (given == "O")
    || (given == "U")) {
  print("\(given) is a vowel")
} else {
  print("\(given) is not a vowel")
}

TypeScript

// Write a TypeScript program to check vowel

function checkVowels(str: string) {
  let isVowel = "";
  if (
    str == "a" ||
    str == "e" ||
    str == "i" ||
    str == "o" ||
    str == "u" ||
    str == "A" ||
    str == "E" ||
    str == "I" ||
    str == "O" ||
    str == "U"
  ) {
    isVowel = "Vowel";
  } else {
    isVowel = "Is not a Vowel";
  }
  return isVowel;
}

console.log(checkVowels("U"));

Similar programs