FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 23   



Following program shows you how to take a character and tells its vowel or consonant.
In this program we get a character from user and shows it's vowel or consonant using if condition

package main

import "fmt"

func main() {
  var input  int
  fmt.Print("Enter a character:")
  fmt.Scanf("%c",&input)
  if (input == 'a' || input == 'A' || input == 'e' || input == 'E' || input == 'i' || input == 'I' || input == 'o' || input == 'O' || input == 'u' || input == 'U') {
    fmt.Println("Its a vowel")
  } else if ((input >= 'a' && input <= 'z') || (input >= 'A' && input <= 'Z')) {
    fmt.Println("Its a consonant")
  } else {
    fmt.Println("Invalid input please enter an alphabet")
  }
  }

Output:

Example1:

Enter a character: e
Its a vowel

Example2:

Enter a character: x
Its a consonant

Example3:

Enter a character: 4
Invalid input please enter an alphabet



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News