top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to double the number of vowels in a given string using C?

+1 vote
1,057 views

double the number of vowels in a given string using c programming language
Ex:
Given String="Maven"
Output Required="Maaveen".

posted Mar 17, 2014 by Rahul Mehra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Try the following code (tested)

#include <stdio.h>
#include <string.h>

int check_vowel(char);

int main()
{
  char s[]="Maven", t[100];
  int i, j = 0;


  for(i = 0; s[i] != '\0'; i++) 
  {
    if(check_vowel(s[i]) == 0) 
    {       //not a vowel
      t[j] = s[i];
      j++;
    }
    else
    {
      t[j]= s[i];
      j++;
      t[j]= s[i];
      j++;
    }
  }

  t[j] = '\0';

  printf("String after repeating vowels: %s\n", t);

  return 0;
}


int check_vowel(char c)
{
  switch(c) {
    case 'a':
    case 'A':
    case 'e':
    case 'E':
    case 'i':
    case 'I':
    case 'o':
    case 'O':
    case 'u':
    case 'U':
      return 1;
    default:
      return 0;
  }
}
answer Mar 17, 2014 by Salil Agrawal
Similar Questions
+8 votes

Convert the given string into palindrome with minimum number of appends(at end of the given string). O(n) algorithm will be appreciated ??

Input :=> Malayal
Output :=> Malayalam

+3 votes

Please help me to print all permutations of a string in C?

+3 votes

Say the given string is ABC

Output should be ABC ACB BAC BCA CBA CAB

...