Q:

C Program To Check Vowel or Consonant

belongs to collection: Basic C Programming Examples

0

you have to make this program in the following way:

  • C Program To Check Vowel or Consonant Using if else
  • C Program To Check Vowel or Consonant Using Switch Case
  • C Program To Check Vowel or Consonant Using Function

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C Program To Check Vowel or Consonant Using If else Statement

Algorithm

  • Program Start
  • Declare Variable
  • Input Character
  • Check Conditions
  • Display Result Accourding to condition
  • Program End

Program

//C Program To Check Vowel or Consonant Using If else Statement 

#include <stdio.h>
void main()
{
  char ch;

  printf("Enter a character : ");
  scanf("%c", &ch);

  // Checking both lower and upper case, || is the OR operator

  if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U')
    printf("%c is a vowel.\n", ch);
  else
    printf("%c isn't a vowel it is a Consonant\n", ch);

}

Output

Enter a character : t
t isn't a vowel it is a Consonant

C Program To Check Vowel or Consonant Using Switch Case Statement

Program

//C Program To Check Vowel or Consonant Using Switch Case Statement

#include <stdio.h>
void main()
{
  char ch;

  printf("Enter a character : ");
  scanf("%c", &ch);

  switch(ch)
  {
    case 'a':
    case 'A':
    case 'e':
    case 'E':
    case 'i':
    case 'I':
    case 'o':
    case 'O':
    case 'u':
    case 'U':
      printf("%c is a vowel.\n", ch);
      break;
    default:
      printf("%c isn't a vowel it is a Consonant\n", ch);

}
}

Output

Enter a character : e
e is a vowel.

C Program To Check Vowel or Consonant Using Function

Algorithm

  • Program Start
  • Declare Variable
  • Input Character
  • Calling Function To Check Vowel Or Consonant
  • Check Conditions
  • Display Result Accourding to condition
  • Program End

Program

//C Program To Check Vowel or Consonant Using Switch Case Statement

#include <stdio.h>
void main()
{
  char ch;

  printf("Enter a character : ");
  scanf("%c", &ch);

  switch(ch)
  {
    case 'a':
    case 'A':
    case 'e':
    case 'E':
    case 'i':
    case 'I':
    case 'o':
    case 'O':
    case 'u':
    case 'U':
      printf("%c is a vowel.\n", ch);
      break;
    default:
      printf("%c isn't a vowel it is a Consonant\n", ch);

}
}

Output

Enter a character : e
e is a vowel.

C Program To Check Vowel or Consonant Using Function

Algorithm

  • Program Start
  • Declare Variable
  • Input Character
  • Calling Function To Check Vowel Or Consonant
  • Check Conditions
  • Display Result Accourding to condition
  • Program End

Program

//C Program To Check Vowel or Consonant Using Function

#include <stdio.h>
void checkvowelorConsonant(char ch)
{
// Checking both lower and upper case, || is the OR operator

  if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U')
    printf("%c is a vowel.\n", ch);
  else
    printf("%c isn't a vowel\n", ch);

}
void main()
{
  char ch;

  printf("Enter a character : ");
  scanf("%c", &ch);

  checkvowelorConsonant(ch);
}

Output

Enter a character : O
O is a vowel.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Basic C Programming Examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program to Calculate Power of a Number... >>
<< C Program To Find Factorial of a Number...