Description
To check entered character is vowel or consonant, follow the following program.
To check entered character is vowel or consonant, follow the following program.
To check entered character is vowel or consonant, follow the following program.
C/C++
/* C Program to check entered character is vowel or consonants */
//Save it as CheckVowelAndConsonant.c
#include<stdio.h>
int main(){
char val;
printf("Enter a character : ");
scanf("%c",&val);
//Checking the entered character is alphabet or not
if((val>='a' && val<='z') || (val>='A' && val<='Z')) {
//Checking the entered character is vowel or not
if(val=='a' || val=='A' || val=='e' || val=='E' || val=='i' || val=='I' ||
val=='o' || val=='O' || val=='u' || val=='U'){
printf("The %c is vowel",val);
}else{
printf("The %c is consonant",val);
}
}else {
printf("%c is neither vowel nor consonant",val);
}
return 0;
}
/* C Program to check entered character is vowel or consonants */
//Save it as CheckVowelAndConsonant.c
#include<stdio.h>
int main(){
char val;
printf("Enter a character : ");
scanf("%c",&val);
//Checking the entered character is alphabet or not
if((val>='a' && val<='z') || (val>='A' && val<='Z')) {
//Checking the entered character is vowel or not
if(val=='a' || val=='A' || val=='e' || val=='E' || val=='i' || val=='I' ||
val=='o' || val=='O' || val=='u' || val=='U'){
printf("The %c is vowel",val);
}else{
printf("The %c is consonant",val);
}
}else {
printf("%c is neither vowel nor consonant",val);
}
return 0;
}
/* C Program to check entered character is vowel or consonants */ //Save it as CheckVowelAndConsonant.c #include<stdio.h> int main(){ char val; printf("Enter a character : "); scanf("%c",&val); //Checking the entered character is alphabet or not if((val>='a' && val<='z') || (val>='A' && val<='Z')) { //Checking the entered character is vowel or not if(val=='a' || val=='A' || val=='e' || val=='E' || val=='i' || val=='I' || val=='o' || val=='O' || val=='u' || val=='U'){ printf("The %c is vowel",val); }else{ printf("The %c is consonant",val); } }else { printf("%c is neither vowel nor consonant",val); } return 0; }
Input:
Enter a character : g
Output:
The g is consonant
Input:
Enter a character : g
Output:
The g is consonant
Input: Enter a character : g Output: The g is consonant
Java
/* Java Program to check entered character is vowel or consonants */
//Save it as CheckVowelAndConsonant.java
import java.io.*;
import java.util.Scanner;
public class CheckVowelAndConsonant {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a character : ");
char val = scanner.next().charAt(0);
//Checking the entered character is alphabet or not
if((val>='a' && val<='z') || (val>='A' && val<='Z')) {
//Checking the entered character is vowel or not
if(val=='a' || val=='A' || val=='e' || val=='E' || val=='i' || val=='I' ||
val=='o' || val=='O' || val=='u' || val=='U'){
System.out.println("The "+val+" is vowel");
}else{
System.out.println("The "+val+" is consonant");
}
}else {
System.out.println(val+" is neither vowel nor consonant");
}
}
}
/* Java Program to check entered character is vowel or consonants */
//Save it as CheckVowelAndConsonant.java
import java.io.*;
import java.util.Scanner;
public class CheckVowelAndConsonant {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a character : ");
char val = scanner.next().charAt(0);
//Checking the entered character is alphabet or not
if((val>='a' && val<='z') || (val>='A' && val<='Z')) {
//Checking the entered character is vowel or not
if(val=='a' || val=='A' || val=='e' || val=='E' || val=='i' || val=='I' ||
val=='o' || val=='O' || val=='u' || val=='U'){
System.out.println("The "+val+" is vowel");
}else{
System.out.println("The "+val+" is consonant");
}
}else {
System.out.println(val+" is neither vowel nor consonant");
}
}
}
/* Java Program to check entered character is vowel or consonants */ //Save it as CheckVowelAndConsonant.java import java.io.*; import java.util.Scanner; public class CheckVowelAndConsonant { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Enter a character : "); char val = scanner.next().charAt(0); //Checking the entered character is alphabet or not if((val>='a' && val<='z') || (val>='A' && val<='Z')) { //Checking the entered character is vowel or not if(val=='a' || val=='A' || val=='e' || val=='E' || val=='i' || val=='I' || val=='o' || val=='O' || val=='u' || val=='U'){ System.out.println("The "+val+" is vowel"); }else{ System.out.println("The "+val+" is consonant"); } }else { System.out.println(val+" is neither vowel nor consonant"); } } }
Input:
Enter a character :
g
Output:
The g is consonant
Input:
Enter a character :
g
Output:
The g is consonant
Input: Enter a character : g Output: The g is consonant
Related Programs
1) Program to Check Whether a Character is a Vowel or Not2) Program to Find ASCII value of a character
3) Program to remove vowels from a String
4) Program to count Vowels, Consonants, Digits and Whitespaces
5) Program to Replace Spaces With Dots
6) Program to find maximum number of 1s in a substring of a String
7) Count Number of Words in a String
8) Find Occurrence Of Each Word In a Sentence
9) Print All Unique Words Of A String
10) Program To Print Unique Word Of A String Using Set