Sunday, 20 March 2016

C Program For Remove All Vowels From A String Using Switch Case

#include<stdio.h>
#include<string.h>
int isThisVowel(char);

void main()
{
 char str[100],new[100];
 int i,j=0;

 printf("Enter a string to remove vowels from\n");
 gets(str);

 for(i = 0; str[i] != '\0'; i++)
 {
  if(isThisVowel(str[i]) == 1)
  {
   new[j] = str[i];
   j++;
  }
 }

 new[j] = '\0';
 printf("String after removing vowels: \n%s", new);
 getch();
}

int isThisVowel(char c)
{
 switch(c)
 {
  case 'a':
  case 'e':
  case 'i':
  case 'o':
  case 'u':
  case 'A':
  case 'E':
  case 'I':
  case 'O':
  case 'U':
  return 0;
  default:
  return 1;
 }
}

Output:-


No comments:
Write comments

Recommended Posts × +