C Programming – HackerRank Solution | Vowels and Consonants 9 |

Write a Modular C Programming code to find out the count of Vowels and Consonants

Ranu is learning the alphabet. The teacher is teaching alphabets, but he is finding it difficult in differentiating between vowels and consonants.

Write a program to help Ranu to learn a character (C) as input and check whether the given character is a vowel or a consonant.

NOTE:− Vowels are ‘A’, ‘E’, ‘I’, ‘O’, ‘U’. Rest all alphabets are called consonants.

Input Format

First-line will contain the character C.

Constraints

C will be an upper case English alphabet

Output Format

Print “Vowel” if the given character is a vowel, otherwise print “Consonant”.

Sample Input 0

A

Sample Output 0

Vowel

Sample Input 1

*

Sample Output 1

Invalid alphabet

Refer : C Programming HackerRank all solutions for Loops | Arrays | strings

 

CODE:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>


int main() {
    char c;
    scanf("%c",&c);
    if(c>='A'&&c<='Z')
    {
    if(c=='A'||c=='I'||c=='E'||c=='O'||c=='U')
    {
        printf("Vowel");
    }
        else
        printf("Consonant");
    }
    else
        printf("Invalid alphabet");
    
}

OUTPUT

Congratulations, you passed the sample test case.

Click the Submit Code button to run your code against all the test cases.

Input (stdin)

A
Your Output (stdout)

Vowel
Expected Output

Vowel

 

Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, MISC, Solved model question papers & Hacker Rank all solutions on the below page:

Top 100+ C Programming codes – KLE Technological University

Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

Welcome to FactsPrime

Sorry, We have detected that you have activated Ad-Blocker. Please Consider supporting us by disabling your Ad Blocker, It helps us in maintaining this website. To View the content, Please disable adblocker and refresh the page.

Thank You !!!