Online C++ Compiler

// Iterative CPP program #include <iostream> using namespace std; // Function to check for consonant bool consonant(char ch){ // To handle lower case ch = toupper(ch); return !(ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U') && ch >= 65 && ch <= 90; } //function to count consonant int countconsonants(string s){ int result = 0; for (int i = 0; i < s.length(); i++){ // To check is character is Consonant if (consonant(s[i])) { ++result; } } return result; } // main function int main(){ string s = "wx abc def"; cout <<"count is: "<<countconsonants(s); return 0; }