Enter the string find total number of vowels replace it with star using switch case statement

Write a program to enter the user define string and print it. Also find the total number of vowels in given string and put * in replace of every vowel using switch case statement.


Source Code:

#include<stdio.h>
#include<conio.h>
void main()
{
	char a[20];
	int i,j,count=0;
	clrscr();
	printf("Enter the String:");
	gets(a);
        printf("Given String is:\n");
	for(i=0;a[i]!=NULL;i++)
	{
		printf("%c",a[i]);
	}
	for(i=0;a[i]!=NULL;i++)
	{
		switch(a[i])
		{
			case 'a':
			case 'e':
			case 'i':
			case 'o':
			case 'u':
			case 'A':
			case 'E':
			case 'I':
			case 'O':
			case 'U':
			count ++;
			a[i]='*';
			break;
		}
	}
	printf(" \n Given String is =%s",a);
	getch();
}

Output:

Enter the String: Bhavesh Jain
Given String is: Bhavesh Jain

Given string is: Bh*v*sh J**n

Leave a Reply

Your email address will not be published. Required fields are marked *