Our website is made possible by displaying online advertisements to our visitors.Please consider supporting us by disabling your ad blocker.
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Translate it in your own Language

Print this Job Post

Print Friendly and PDF

Friday, May 2, 2014

C program to check whether input alphabet is a vowel or not

This code checks whether an input alphabet is a vowel or not. Both lower-case and upper-case are checked.

C programming code
#include <stdio.h>
#include<conio.h>
void main()
{
  char ch;
  printf("Enter a character\n");
  scanf("%c", &ch);
  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 is not a vowel.\n", ch);
  getch();
}

Check vowel using switch statement
#include <stdio.h>
#include<conio.h>
void main()
{
  char ch;
  printf("Input a character\n");
  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 is not a vowel.\n", ch);
  }             
   getch();
}

Function to check vowel

int check_vowel(char a)
{
    if (a >= 'A' && a <= 'Z')
    a = a + 'a' - 'A';   /* Converting to lower case or use a = a + 32 */
    if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
       return 1;
       return 0;
}

No comments:

Post a Comment

Copyright @ CrackMNC 2014-2024
Divas Nikhra Theme by Crack MNC