Step 4 of 6
bool, auto and range-for
A few small upgrades:
boolis a real type withtrueandfalse(no include needed).autolets the compiler deduce a variable's type from its initializer:auto x = 3.5;is adouble.- The range-based for loop visits every element of a string, array or container:
std::string s = "awp";
for (char c : s) {
std::cout << c << "\n";
}
Your turn: write int count_vowels(std::string s) that counts a e i o u (lowercase only) using a range-based for loop.