#include<stdio.h>
#include<conio.h>
#include<string.h>
char vowels(char *p);
void main()
{
char str[10];
clrscr();
printf(" \n \n Enter the string: \t ");
gets(str);
vowels(str);
getch();
}
char vowels(char *p)
{
int i, l, v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0, v6 = 0, v7 = 0, v8 = 0, v9 = 0, v10 = 0;
l = strlen(p);
printf(" \n \n The number of vowels in the string is: \t ");
for( i = 0; i < l; i++ )
{
if ( p[i] == 'a' )
{
v1++;
}
if ( p[i] == 'e' )
{
v2++;
}
if ( p[i] == 'i' )
{
v3++;
}
if ( p[i] == 'o' )
{
v4++;
}
if ( p[i] == 'u' )
{
v5++;
}
if ( p[i] == 'A' )
{
v6++;
}
if ( p[i] == 'E' )
{
v7++;
}
if ( p[i] == 'I' )
{
v8++;
}
if ( p[i] == 'O' )
{
v9++;
}
if ( p[i] == 'U' )
{
v10++;
}
else
continue;
}
printf ( "a = %d e = %d i = %d o = %d u = %d
A = %d E = %d I = %d O = %d U = %d",v1, v2, v3, v4, v5, v6, v7, v8, v9, v10 );
return 1;
}
OUTPUT:
Enter the string: Facebook
The number of vowels in the string is: a = 1 e = 1 o = 2
ALSO READ:
Sample C Program To Accept A String & Display Vowels.
Sample C Program To Accept A String & Display Number Of Vowels.
Sample C Program To Swap Two Strings Using strcpy() Function.
Sample C Program To Sort A Given Number Of Strings Using strcmp() Function.
Sample C Program To Check Whether A String Is Palindrome Or Not.
Sample C Program To Print The Reverse Of A String.
Comments
Post a Comment
Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...
Experienced guys can share their resumes at admin@interview-made-easy.com