C Program to Check Vowel or Consonant

Introduction

The C programming language is a procedural programming language. Between 1969 and 1973, Dennis Ritchie worked on the project. It was created primarily as a system programming language for developing operating systems.

In order to understand the code given below you’ve got to have prior knowledge and or understanding of the following topics:

If you have a sound knowledge and understanding of what the functions of the concepts are then there will be no difficulty in understanding the given codes below. With all that said lets get coding!

Why Learn C Programming Language?

Because it mixes the characteristics of high-level languages with the functionalism of assembly language, C is often referred to as a middle-level computer language. The manipulation of bits, bytes, and addresses in C gives the programmer more control over how the program will behave and more direct access to the underlying hardware mechanisms.

Working programmers influenced, influenced, and field-tested C. As a result, C provides the programmer with exactly what he or she want. C++ is a more advanced version of the C programming language. C++ incorporates all of the features of C, as well as support for object-oriented programming (OOP). Furthermore, C++ includes numerous enhancements and features that make it a “better C,” regardless of whether or not it is used for object-oriented programming.

Vowels and Consonant Checker in C

The English alphabet is made up of 26 letters, 5 out of which (a, e, i, o, u) are Vowels. The rest of the 21 alphabets are known as Consonant.

The best way to learn is to do. Hence, what better way to learn C programming language (if you know the basics) than to code your first mini project. In this tutorial we are going to build a Vowels and Consonant Checker in c programming language. Keep in mind this is a mini project for absolute beginners and intermediate programmers as well.

Method 1: Using if…else statements

// C program to check weather the given alphabet entered by the user is...
// ... a alphabet or consonant.
// Done using if else statements (method 1)
#include <stdio.h>
#include <stdlib.h>    
#include <conio.h>    
#include <string.h>    

int main()
{    
char c;    
printf("Please enter any single alphabet:");  
scanf("%s",&c); 
if(c == 'a' || c == 'A')
{
printf("%s is a vowel", &c);    
}
else if (c == 'e' || c == 'E')
{
printf("%s is a vowel", &c);
}
else if (c == 'i' || c == 'I')
{
printf("%s is a vowel", &c);
}
else if (c == 'o' || c == 'O')
{
printf("%s is a vowel", &c);
}
else if (c == 'u' || c == 'U')
{
printf("%s is a vowel", &c);
}
else
{
    printf("%s is a consonant", &c);
}
return 0;  
}   

Method 2: Using Switch Cases

To understand C switch cases checkout: C switch…case.

// C program to check weather the given alphabet entered by the user is...
// ... a alphabet or consonant.
// Done using if switch cases (method 2)

#include<stdio.h>
#include <stdlib.h>    
#include <conio.h>    
#include <string.h>
   
int main()
{    
char c;    
printf("Please enter any single alphabet: ");  
scanf("%s",&c);
// switch cases 
switch(c)
{
case 'a':
printf("a is  vowel");
break;
case 'e':
printf("e is  vowel");
break;
case 'i':
printf("i is  vowel");
break;
case 'o':
printf("o is  vowel");
break;
case 'u':
printf("u is  vowel");
break;
// the default message is "it's constant"
default:
printf("its consonant");
}
return 0;  
}    

Output

SHARE C Program to Check Vowel or Consonant

You may also like...

Leave a Reply

Your email address will not be published.

Share