Write a program to check if the given character is a vowel or consonant.
this is a java program.any1 answer plz.....fast!!
nashabhi612:
Hi sam
Answers
Answered by
6
public class VowelConsonant {
public static void main(String[] args) {
//Enter any character
char ch = 'f';
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U'){
System.out.println(ch + " is vowel");
}
else {
System.out.println(ch + " is consonant");
}
}
}
Answered by
4
#include <stdio.h> int main() { char c; int isLowercaseVowel, isUppercaseVowel; printf("Enter an alphabet: "); scanf("%c",&c); // evaluates to 1 (true) if c is a lowercase vowel isLowercaseVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'); // evaluates to 1 (true) if c is an uppercase vowel isUppercaseVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'); // evaluates to 1 (true) if either isLowercaseVowel or isUppercaseVowel is true if (isLowercaseVowel || isUppercaseVowel) printf("%c is a vowel.", c); else printf("%c is a consonant.", c); return 0; }
Similar questions
Social Sciences,
7 months ago
English,
7 months ago
English,
7 months ago
English,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago