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 30, 2014

remove vowels string c

c program to remove or delete vowels from a string, if the input string is "c programming" then output will be "c programming". In the program we create a new string and process entered string character by character, and if a vowel is found it is not added to new string otherwise the character is added to new string, after the string ends we copy the new string into original string. Finally we obtain a string without any vowels.

C programming code

#include <stdio.h>
#include <string.h>
int check_vowel(char);
int main()
  char s[100], t[100];
  int i, j = 0;
  printf("Enter a string to delete vowels\n");
  for(i = 0; s[i] != '\0'; i++) 
    if(check_vowel(s[i]) == 0) 
      t[j] = s[i];
  t[j] = '\0';
  strcpy(s, t);    
  printf("String after deleting vowels: %s\n", s);
 int check_vowel(char c)
    case 'a':
    case 'A':
    case 'e':
    case 'E':
    case 'i':
    case 'I':
    case 'o':
    case 'O':
    case 'u':
    case 'U':
      return 1;
      return 0;

C programming code using pointers

#define TRUE 1
#define FALSE 0
int check_vowel(char);
void main()
   char string[100], *temp, *pointer, ch, *start;
   printf("Enter a string\n");
   temp = string;
   pointer = (char*)malloc(100);
   if( pointer == NULL )
      printf("Unable to allocate memory.\n");
   start = pointer;
      ch = *temp;
      if ( !check_vowel(ch) )
         *pointer = ch;
   *pointer = '\0';
   pointer = start;
   strcpy(string, pointer); /* If you wish to convert original string */
   printf("String after removing vowel is \"%s\"\n", string);
int check_vowel(char a)
   if ( a >= 'A' && a <= 'Z' )
   a = a + 'a' - 'A';
   if ( a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
      return TRUE;
   return FALSE;

No comments:

Post a Comment

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