-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
51 lines (38 loc) · 1.15 KB
/
main.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <vector>
int main()
{
// Test conditions
std::vector <char> vec{'f', 'r', 'a', 'n', 'k'};
//std::vector <char> vec{'F', 'R', 'A', 'N', 'K'};
//std::vector <char> vec{'h', 'e', 'l', 'l', 'o'};
//std::vector <char> vec{};
//std::vector <char> vec{'x', 'y', 'z', 'o'};
int count{ 0 };
size_t index{ 0 };
if (vec.size() != 0) { // Check vector isn't empty first
do {
switch (vec.at(index))
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
std::cout << "Vowel found: " << vec.at(index);
++count; // Set condition for not outputting the "No vowel was found message"
index = vec.size(); // Force loop termination
break;
default:
break;
}
++index; // Move on to next vector index
} while (index < vec.size());
if (!count)
std::cout << "No vowel was found";
}
else { // Condition if vector is empty.
std::cout << "No vowel was found";
}
return 0;
}