Skip to content
Home » C Program to find Character is vowel or consonant using Pointer

C Program to find Character is vowel or consonant using Pointer

Learn about C Program to find Character is vowel or consonant using Pointer in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

C Program to find Character is vowel or consonant using Pointer

Generally A,I,E,O,U and a,e,i,o,u are known to be vowels and hence here we check whether it is vowel or not using pointer. variable is declared and pointer is assigned to it. so it can be accessed.

#include<stdio.h>
int main()
{
  char c, *pc;
  pc= &c;
  printf("Enter a character: ");
  scanf("%c", pc);
  if( (*pc=='A'||*pc=='E'||*pc=='I'||*pc=='O'||*pc=='U') ||
      (*pc=='a'||*pc=='e'||*pc=='i'||*pc=='o'||*pc=='u') )//checking for vowel
    printf("%c is Vowel.\n", *pc);
  else
    printf("%c is consonant.\n", *pc);
  return 0;
}

Output:

Enter a character: d
d is consonant.

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Find Sum & average in Range using Pointer & Function
C Program to Find Sum and average in Range using Pointer