-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvowels-in-text.c
More file actions
36 lines (30 loc) · 772 Bytes
/
vowels-in-text.c
File metadata and controls
36 lines (30 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
This program will ask for an input from user
then will iterate through the text for counting
the number of vowels in text.
*/
#include<stdio.h>
#include<string.h>
int main(){
// Define required variables
int i;
int v = 0;
char name[99] = "";
// Ask for user input
printf("Enter Text: ");
scanf("%[^\n]s", name);
for(i=0; i <= strlen(name); i++){
// Check if the char is a vowel
if(name[i]=='a' || name[i]=='e' || name[i]=='i' ||
name[i]=='o' || name[i]=='u' ||
name[i]=='A' || name[i]=='E' || name[i]=='I' ||
name[i]=='O' || name[i]=='U'
){
// Found a vowel
v++;
}
}
// Output result
printf("Total Vowel: %d", v);
return 0;
}