C Program to Check Vowel or Consonant

C program to check vowel or consonant; Through this tutorial, we will learn how to check whether an alphabet is vowel or consonant using function, ascii value and if else in c program.

Programs to Check Vowel or Consonant in C

  • C program to check whether an alphabet is vowel or consonant using if else
  • C Program to find Vowel or Consonant using Functions
  • C Program to Check Vowel or Consonant using ASCII Values

C program to check whether an alphabet is vowel or consonant using if else

// C Program to Check Vowel or Consonant
#include <stdio.h>

int main()
{
    char ch;

    printf("Please Enter an alphabet: ");
    scanf(" %c", &ch);

    if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||
		ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')  {
		printf("\n %c is a VOWEL.", ch);
	}
    else {
    	printf("\n %c is a CONSONANT.", ch);
	}
    return 0;
}

The output of the above c program; as follows:

Please Enter an alphabet: i
i is a VOWEL.

C Program to find Vowel or Consonant using Functions

// C Program to Check Whether an Alphabet is Vowel or Consonant
#include <stdio.h>
int check_vowel(char a);
int main()
{
    char ch;
    printf("Please Enter an alphabet: ");
    scanf(" %c", &ch);

    if(check_vowel(ch))  {
		printf("\n %c is a VOWEL.", ch);
	}
    else {
    	printf("\n %c is a CONSONANT.", ch);
	}
    return 0;
}

int check_vowel(char c)
{
    if (c >= 'A' && c <= 'Z')
       c = c + 32;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
       return 1;

    return 0;
}

The output of the above c program; as follows:

Please Enter an alphabet: g
g is a CONSONANT.

C Program to Check Vowel or Consonant using ASCII Values

// C Program to Check Whether it is Vowel or Consonant
#include <stdio.h>

int main()
{
    char ch;

    printf("Please Enter an alphabet: ");
    scanf(" %c", &ch);

    if(ch == 97 || ch == 101 || ch == 105 || ch == 111 || ch == 117 ||
	ch == 65 || ch == 69 || ch == 73 || ch == 79 || ch == 85)
    {
    	printf("%c is a VOWEL.\n", ch);
    }
    else if((ch >= 97 && ch <= 122) || (ch >= 65 && ch <= 90))
    {
        printf("%c is a CONSONANT.\n", ch);
    }

    return 0;
}

The output of the above c program; as follows:

Please Enter an alphabet: a
a is a VOWEL.

Recommended C Programs

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *