Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- int isVowel(char ch);
- int isConsonant(char ch);
- int main() {
- char s1[51], s2[51];
- cout << "Enter first string: ";
- cin >> s1;
- cout << "Enter second string: ";
- cin >> s2;
- for (int i = 0; i < strlen(s1); i++) {
- if (isVowel(s1[i]) && isVowel(s2[i])) {
- cout << "*";
- }
- else if (isConsonant(s1[i]) && isConsonant(s2[i])) {
- cout << "#";
- }
- else {
- cout << "?";
- }
- }
- return 0;
- }
- int isVowel(char ch) {
- return strchr("aeiou", ch) != NULL;
- }
- int isConsonant(char ch) {
- if (!isVowel(ch) && (ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z')) {
- return 1;
- }
- else {
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment