#include<iostream.h>
#include<stdlib.h>
const int MAXCHARS = 500;
char st_line[MAXCHARS];
char ch_option;
int i_va;
int i_ve;
int i_vi;
int i_vo;
int i_vu;
int i_word;
int i_count = 1;
int i_number = 0;
int i_vowel = 0;
char ch_char;
void getdata();
void vowels();
void words();
void putdata();
int main()
{
do{
getdata();
vowels();
words();
putdata();
}while(ch_option != 'y');
}
void getdata()
{
cout << "\nPlease enter line of text:\n";
cin.getline(st_line,MAXCHARS);
vowels();
}
void vowels()
{
while((ch_char = st_line[i_number++]) != '\0')
switch(ch_char)
{
case 'a': case 'A':
ch_char = i_va;
case 'e': case 'E':
ch_char = i_ve;
case 'i': case 'I':
ch_char = i_vi;
case 'o': case 'O':
ch_char = i_vo;
case 'u': case 'U':
ch_char = i_vu;
i_vowel++;
}
return;
}
void words()
{
if(st_line[i_word] == ' ' || st_line[i_word] == '\0')
i_count--;
while(st_line[i_word] != '\0')
{
if(st_line[i_word] == ' ' && (st_line[i_word + 1] != ' ' && st_line[i_word + 1
] != '\0'))
i_count++;
i_word++;
}
return;
}
void putdata()
{
cout << "\nInputted String";
cout << "\n\n*******************************";
cout << "\n\n " << st_line;
cout << "\n\nNumber of a's: " << i_va;
cout << "\nNumber of e's: " << i_ve;
cout << "\nNumber of i's: " << i_vi;
cout << "\nNumber of o's: " << i_vo;
cout << "\nNumber of u's: " << i_vu;
cout << "\nTotal Vowels: "<< i_vowel;
cout << "\n\nNumber of Words: " << i_word;
cout << "\n\n\nDo you want to exit (Y/N)? ";
cin.get(ch_option);
}
hopeolicious 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.