codescracker


c

C Program to Delete Vowels from String



« Previous Program Next Program »


Delete Vowels from String in C

To delete vowels from the string in C programming, you have to ask to the user to enter the string, now start checking for vowel (a, A, e, E, i, I, o, O, u, U). If any one found of the 10 then place the next character after the found to the back until the last and so on

C Programming Code to Delete Vowels from String

Following C program ask to the user to enter a string to find the vowel present in that string then delete the vowel and form the new string, then display the result on the screen:

/* C Program - Delete Vowels from String */
		
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
	clrscr();
	char str[20];
	int len, i, j;
	printf("Enter a string : ");
	gets(str);
	len=strlen(str);
	for(i=0; i<len; i++)
	{
		if(str[i]=='a' || str[i]=='e' || str[i]=='i' ||
		str[i]=='o' || str[i]=='u' || str[i]=='A' ||
		str[i]=='E' || str[i]=='I' || str[i]=='O' ||
		str[i]=='U')
		{
			for(j=i; j<len; j++)
			{
				str[j]=str[j+1];
			}
		len--;
		}
	}
	printf("After deleting the vowels, the string will be : %s",str);
	getch();
}

When the above c program is compile and executed, it will produce the following result:

c program delete vowels from string

Same Program in Other Programming Language

You may also like same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test