Skip to content

Commit 577920e

Browse files
Occurrence checking of vowels in string program
1 parent 159bd2b commit 577920e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

string8.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Write a function to count the occurrence of vowels in a string.
2+
#include<stdio.h>
3+
#include<string.h>
4+
void occurrence(char str[]);
5+
int main()
6+
{
7+
char str[100];
8+
printf("Enter your string : ");
9+
fgets(str,100,stdin);
10+
occurrence(str);
11+
return 0;
12+
}
13+
void occurrence(char str[])
14+
{
15+
int count=0;
16+
strlwr(str);
17+
for(int i=0;i<strlen(str);i++)
18+
{
19+
if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u')
20+
{
21+
count++;
22+
}
23+
24+
}
25+
printf("Entered string contains %d vowels \n",count);
26+
}

string8.exe

42.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)