Instructions:
Code:
#include <iostream>
using namespace std;
// TODO: Declare the hasConsonant() function here
int hasConsonant(int code)
int main(void) {
char code[100];
cout << "Enter the code: ";
cin >> code;
int result = hasConsonant(code);
if(result == 1) {
cout << "ALERT! There is a consonant in the code!";
} else if(result == 0) {
cout << "There is no consonant in the code. Situation is under control!";
}
return 0;
}
// TODO: Define the hasConsonant() function here
#include <iostream>
using namespace std;
// TODO: Declare the hasConsonant() function here
int hasConsonant(char[100]);
int hasConsonant(int code);
int main() {
char code[100];
cout << "Enter the code: ";
cin >> code;
int result = hasConsonant(code);
if(result == 1) {
cout << "ALERT! There is a consonant in the code!";
}
else if(result == 0) {
cout << "There is no consonant in the code. Situation is under control!";
}
return 0;
}
// TODO: Define the hasConsonant() function here
int hasConsonant(char* text){
for(int i =0;i<100;i++){
switch(text[i]){
case 'a': case 'o': case 'u': case 'e': case 'y': case 'i': return 1;
}
}
return 0;
}
Comments